- commit
- b7717ad7b73c3c5357b272c987b9999c9466f897
- parent
- 766f6180605eb503faa11834cf36a694027bed9f
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2022-07-15 05:41
build
Diffstat
| M | babel.js | 40298 | ++++++++++++------------------------------------------------- |
| M | fuzz.js | 232 | +++++++++++++++++++++++++++++++------------------------------ |
2 files changed, 7624 insertions, 32906 deletions
diff --git a/babel.js b/babel.js
@@ -1,28552 +1,2148 @@ 1 1 (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){2 -1 'use strict';3 -14 -1 const asn1 = exports;5 -16 -1 asn1.bignum = require('bn.js');7 -18 -1 asn1.define = require('./asn1/api').define;9 -1 asn1.base = require('./asn1/base');10 -1 asn1.constants = require('./asn1/constants');11 -1 asn1.decoders = require('./asn1/decoders');12 -1 asn1.encoders = require('./asn1/encoders');13 -114 -1 },{"./asn1/api":2,"./asn1/base":4,"./asn1/constants":8,"./asn1/decoders":10,"./asn1/encoders":13,"bn.js":15}],2:[function(require,module,exports){15 -1 'use strict';16 -117 -1 const encoders = require('./encoders');18 -1 const decoders = require('./decoders');19 -1 const inherits = require('inherits');20 -121 -1 const api = exports;-1 2 // shim for using process in browser -1 3 var process = module.exports = {}; 22 423 -1 api.define = function define(name, body) {24 -1 return new Entity(name, body);25 -1 };-1 5 // cached from whatever global is present so that test runners that stub it -1 6 // don't break things. But we need to wrap it in a try catch in case it is -1 7 // wrapped in strict mode code which doesn't define any globals. It's inside a -1 8 // function because try/catches deoptimize in certain engines. 26 927 -1 function Entity(name, body) {28 -1 this.name = name;29 -1 this.body = body;-1 10 var cachedSetTimeout; -1 11 var cachedClearTimeout; 30 1231 -1 this.decoders = {};32 -1 this.encoders = {};-1 13 function defaultSetTimout() { -1 14 throw new Error('setTimeout has not been defined'); 33 15 } -1 16 function defaultClearTimeout () { -1 17 throw new Error('clearTimeout has not been defined'); -1 18 } -1 19 (function () { -1 20 try { -1 21 if (typeof setTimeout === 'function') { -1 22 cachedSetTimeout = setTimeout; -1 23 } else { -1 24 cachedSetTimeout = defaultSetTimout; -1 25 } -1 26 } catch (e) { -1 27 cachedSetTimeout = defaultSetTimout; -1 28 } -1 29 try { -1 30 if (typeof clearTimeout === 'function') { -1 31 cachedClearTimeout = clearTimeout; -1 32 } else { -1 33 cachedClearTimeout = defaultClearTimeout; -1 34 } -1 35 } catch (e) { -1 36 cachedClearTimeout = defaultClearTimeout; -1 37 } -1 38 } ()) -1 39 function runTimeout(fun) { -1 40 if (cachedSetTimeout === setTimeout) { -1 41 //normal enviroments in sane situations -1 42 return setTimeout(fun, 0); -1 43 } -1 44 // if setTimeout wasn't available but was latter defined -1 45 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { -1 46 cachedSetTimeout = setTimeout; -1 47 return setTimeout(fun, 0); -1 48 } -1 49 try { -1 50 // when when somebody has screwed with setTimeout but no I.E. maddness -1 51 return cachedSetTimeout(fun, 0); -1 52 } catch(e){ -1 53 try { -1 54 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally -1 55 return cachedSetTimeout.call(null, fun, 0); -1 56 } catch(e){ -1 57 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error -1 58 return cachedSetTimeout.call(this, fun, 0); -1 59 } -1 60 } 34 6135 -1 Entity.prototype._createNamed = function createNamed(Base) {36 -1 const name = this.name;37 -138 -1 function Generated(entity) {39 -1 this._initNamed(entity, name);40 -1 }41 -1 inherits(Generated, Base);42 -1 Generated.prototype._initNamed = function _initNamed(entity, name) {43 -1 Base.call(this, entity, name);44 -1 };45 -146 -1 return new Generated(this);47 -1 };48 -149 -1 Entity.prototype._getDecoder = function _getDecoder(enc) {50 -1 enc = enc || 'der';51 -1 // Lazily create decoder52 -1 if (!this.decoders.hasOwnProperty(enc))53 -1 this.decoders[enc] = this._createNamed(decoders[enc]);54 -1 return this.decoders[enc];55 -1 };56 6257 -1 Entity.prototype.decode = function decode(data, enc, options) {58 -1 return this._getDecoder(enc).decode(data, options);59 -1 };-1 63 } -1 64 function runClearTimeout(marker) { -1 65 if (cachedClearTimeout === clearTimeout) { -1 66 //normal enviroments in sane situations -1 67 return clearTimeout(marker); -1 68 } -1 69 // if clearTimeout wasn't available but was latter defined -1 70 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { -1 71 cachedClearTimeout = clearTimeout; -1 72 return clearTimeout(marker); -1 73 } -1 74 try { -1 75 // when when somebody has screwed with setTimeout but no I.E. maddness -1 76 return cachedClearTimeout(marker); -1 77 } catch (e){ -1 78 try { -1 79 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally -1 80 return cachedClearTimeout.call(null, marker); -1 81 } catch (e){ -1 82 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. -1 83 // Some versions of I.E. have different rules for clearTimeout vs setTimeout -1 84 return cachedClearTimeout.call(this, marker); -1 85 } -1 86 } 60 8761 -1 Entity.prototype._getEncoder = function _getEncoder(enc) {62 -1 enc = enc || 'der';63 -1 // Lazily create encoder64 -1 if (!this.encoders.hasOwnProperty(enc))65 -1 this.encoders[enc] = this._createNamed(encoders[enc]);66 -1 return this.encoders[enc];67 -1 };68 8869 -1 Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {70 -1 return this._getEncoder(enc).encode(data, reporter);71 -1 };72 8973 -1 },{"./decoders":10,"./encoders":13,"inherits":132}],3:[function(require,module,exports){74 -1 'use strict';-1 90 } -1 91 var queue = []; -1 92 var draining = false; -1 93 var currentQueue; -1 94 var queueIndex = -1; 75 9576 -1 const inherits = require('inherits');77 -1 const Reporter = require('../base/reporter').Reporter;78 -1 const Buffer = require('safer-buffer').Buffer;-1 96 function cleanUpNextTick() { -1 97 if (!draining || !currentQueue) { -1 98 return; -1 99 } -1 100 draining = false; -1 101 if (currentQueue.length) { -1 102 queue = currentQueue.concat(queue); -1 103 } else { -1 104 queueIndex = -1; -1 105 } -1 106 if (queue.length) { -1 107 drainQueue(); -1 108 } -1 109 } 79 11080 -1 function DecoderBuffer(base, options) {81 -1 Reporter.call(this, options);82 -1 if (!Buffer.isBuffer(base)) {83 -1 this.error('Input not Buffer');84 -1 return;85 -1 }-1 111 function drainQueue() { -1 112 if (draining) { -1 113 return; -1 114 } -1 115 var timeout = runTimeout(cleanUpNextTick); -1 116 draining = true; 86 11787 -1 this.base = base;88 -1 this.offset = 0;89 -1 this.length = base.length;-1 118 var len = queue.length; -1 119 while(len) { -1 120 currentQueue = queue; -1 121 queue = []; -1 122 while (++queueIndex < len) { -1 123 if (currentQueue) { -1 124 currentQueue[queueIndex].run(); -1 125 } -1 126 } -1 127 queueIndex = -1; -1 128 len = queue.length; -1 129 } -1 130 currentQueue = null; -1 131 draining = false; -1 132 runClearTimeout(timeout); 90 133 }91 -1 inherits(DecoderBuffer, Reporter);92 -1 exports.DecoderBuffer = DecoderBuffer;93 -194 -1 DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) {95 -1 if (data instanceof DecoderBuffer) {96 -1 return true;97 -1 }98 13499 -1 // Or accept compatible API100 -1 const isCompatible = typeof data === 'object' &&101 -1 Buffer.isBuffer(data.base) &&102 -1 data.constructor.name === 'DecoderBuffer' &&103 -1 typeof data.offset === 'number' &&104 -1 typeof data.length === 'number' &&105 -1 typeof data.save === 'function' &&106 -1 typeof data.restore === 'function' &&107 -1 typeof data.isEmpty === 'function' &&108 -1 typeof data.readUInt8 === 'function' &&109 -1 typeof data.skip === 'function' &&110 -1 typeof data.raw === 'function';111 -1112 -1 return isCompatible;-1 135 process.nextTick = function (fun) { -1 136 var args = new Array(arguments.length - 1); -1 137 if (arguments.length > 1) { -1 138 for (var i = 1; i < arguments.length; i++) { -1 139 args[i - 1] = arguments[i]; -1 140 } -1 141 } -1 142 queue.push(new Item(fun, args)); -1 143 if (queue.length === 1 && !draining) { -1 144 runTimeout(drainQueue); -1 145 } 113 146 }; 114 147115 -1 DecoderBuffer.prototype.save = function save() {116 -1 return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };-1 148 // v8 likes predictible objects -1 149 function Item(fun, array) { -1 150 this.fun = fun; -1 151 this.array = array; -1 152 } -1 153 Item.prototype.run = function () { -1 154 this.fun.apply(null, this.array); 117 155 }; -1 156 process.title = 'browser'; -1 157 process.browser = true; -1 158 process.env = {}; -1 159 process.argv = []; -1 160 process.version = ''; // empty string to avoid regexp issues -1 161 process.versions = {}; 118 162119 -1 DecoderBuffer.prototype.restore = function restore(save) {120 -1 // Return skipped data121 -1 const res = new DecoderBuffer(this.base);122 -1 res.offset = save.offset;123 -1 res.length = this.offset;-1 163 function noop() {} 124 164125 -1 this.offset = save.offset;126 -1 Reporter.prototype.restore.call(this, save.reporter);-1 165 process.on = noop; -1 166 process.addListener = noop; -1 167 process.once = noop; -1 168 process.off = noop; -1 169 process.removeListener = noop; -1 170 process.removeAllListeners = noop; -1 171 process.emit = noop; -1 172 process.prependListener = noop; -1 173 process.prependOnceListener = noop; 127 174128 -1 return res;129 -1 };-1 175 process.listeners = function (name) { return [] } 130 176131 -1 DecoderBuffer.prototype.isEmpty = function isEmpty() {132 -1 return this.offset === this.length;-1 177 process.binding = function (name) { -1 178 throw new Error('process.binding is not supported'); 133 179 }; 134 180135 -1 DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {136 -1 if (this.offset + 1 <= this.length)137 -1 return this.base.readUInt8(this.offset++, true);138 -1 else139 -1 return this.error(fail || 'DecoderBuffer overrun');-1 181 process.cwd = function () { return '/' }; -1 182 process.chdir = function (dir) { -1 183 throw new Error('process.chdir is not supported'); 140 184 }; -1 185 process.umask = function() { return 0; }; 141 186142 -1 DecoderBuffer.prototype.skip = function skip(bytes, fail) {143 -1 if (!(this.offset + bytes <= this.length))144 -1 return this.error(fail || 'DecoderBuffer overrun');145 -1146 -1 const res = new DecoderBuffer(this.base);-1 187 },{}],2:[function(require,module,exports){ -1 188 (function (setImmediate,clearImmediate){(function (){ -1 189 var nextTick = require('process/browser.js').nextTick; -1 190 var apply = Function.prototype.apply; -1 191 var slice = Array.prototype.slice; -1 192 var immediateIds = {}; -1 193 var nextImmediateId = 0; 147 194148 -1 // Share reporter state149 -1 res._reporterState = this._reporterState;-1 195 // DOM APIs, for completeness 150 196151 -1 res.offset = this.offset;152 -1 res.length = this.offset + bytes;153 -1 this.offset += bytes;154 -1 return res;-1 197 exports.setTimeout = function() { -1 198 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); 155 199 };156 -1157 -1 DecoderBuffer.prototype.raw = function raw(save) {158 -1 return this.base.slice(save ? save.offset : this.offset, this.length);-1 200 exports.setInterval = function() { -1 201 return new Timeout(apply.call(setInterval, window, arguments), clearInterval); 159 202 }; -1 203 exports.clearTimeout = -1 204 exports.clearInterval = function(timeout) { timeout.close(); }; 160 205161 -1 function EncoderBuffer(value, reporter) {162 -1 if (Array.isArray(value)) {163 -1 this.length = 0;164 -1 this.value = value.map(function(item) {165 -1 if (!EncoderBuffer.isEncoderBuffer(item))166 -1 item = new EncoderBuffer(item, reporter);167 -1 this.length += item.length;168 -1 return item;169 -1 }, this);170 -1 } else if (typeof value === 'number') {171 -1 if (!(0 <= value && value <= 0xff))172 -1 return reporter.error('non-byte EncoderBuffer value');173 -1 this.value = value;174 -1 this.length = 1;175 -1 } else if (typeof value === 'string') {176 -1 this.value = value;177 -1 this.length = Buffer.byteLength(value);178 -1 } else if (Buffer.isBuffer(value)) {179 -1 this.value = value;180 -1 this.length = value.length;181 -1 } else {182 -1 return reporter.error('Unsupported type: ' + typeof value);183 -1 }-1 206 function Timeout(id, clearFn) { -1 207 this._id = id; -1 208 this._clearFn = clearFn; 184 209 }185 -1 exports.EncoderBuffer = EncoderBuffer;186 -1187 -1 EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) {188 -1 if (data instanceof EncoderBuffer) {189 -1 return true;190 -1 }191 -1192 -1 // Or accept compatible API193 -1 const isCompatible = typeof data === 'object' &&194 -1 data.constructor.name === 'EncoderBuffer' &&195 -1 typeof data.length === 'number' &&196 -1 typeof data.join === 'function';197 -1198 -1 return isCompatible;-1 210 Timeout.prototype.unref = Timeout.prototype.ref = function() {}; -1 211 Timeout.prototype.close = function() { -1 212 this._clearFn.call(window, this._id); 199 213 }; 200 214201 -1 EncoderBuffer.prototype.join = function join(out, offset) {202 -1 if (!out)203 -1 out = Buffer.alloc(this.length);204 -1 if (!offset)205 -1 offset = 0;206 -1207 -1 if (this.length === 0)208 -1 return out;209 -1210 -1 if (Array.isArray(this.value)) {211 -1 this.value.forEach(function(item) {212 -1 item.join(out, offset);213 -1 offset += item.length;214 -1 });215 -1 } else {216 -1 if (typeof this.value === 'number')217 -1 out[offset] = this.value;218 -1 else if (typeof this.value === 'string')219 -1 out.write(this.value, offset);220 -1 else if (Buffer.isBuffer(this.value))221 -1 this.value.copy(out, offset);222 -1 offset += this.length;223 -1 }224 -1225 -1 return out;-1 215 // Does not start the time, just sets up the members needed. -1 216 exports.enroll = function(item, msecs) { -1 217 clearTimeout(item._idleTimeoutId); -1 218 item._idleTimeout = msecs; 226 219 }; 227 220228 -1 },{"../base/reporter":6,"inherits":132,"safer-buffer":161}],4:[function(require,module,exports){229 -1 'use strict';230 -1231 -1 const base = exports;232 -1233 -1 base.Reporter = require('./reporter').Reporter;234 -1 base.DecoderBuffer = require('./buffer').DecoderBuffer;235 -1 base.EncoderBuffer = require('./buffer').EncoderBuffer;236 -1 base.Node = require('./node');237 -1238 -1 },{"./buffer":3,"./node":5,"./reporter":6}],5:[function(require,module,exports){239 -1 'use strict';240 -1241 -1 const Reporter = require('../base/reporter').Reporter;242 -1 const EncoderBuffer = require('../base/buffer').EncoderBuffer;243 -1 const DecoderBuffer = require('../base/buffer').DecoderBuffer;244 -1 const assert = require('minimalistic-assert');245 -1246 -1 // Supported tags247 -1 const tags = [248 -1 'seq', 'seqof', 'set', 'setof', 'objid', 'bool',249 -1 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',250 -1 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',251 -1 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'252 -1 ];253 -1254 -1 // Public methods list255 -1 const methods = [256 -1 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',257 -1 'any', 'contains'258 -1 ].concat(tags);259 -1260 -1 // Overrided methods list261 -1 const overrided = [262 -1 '_peekTag', '_decodeTag', '_use',263 -1 '_decodeStr', '_decodeObjid', '_decodeTime',264 -1 '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',-1 221 exports.unenroll = function(item) { -1 222 clearTimeout(item._idleTimeoutId); -1 223 item._idleTimeout = -1; -1 224 }; 265 225266 -1 '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',267 -1 '_encodeNull', '_encodeInt', '_encodeBool'268 -1 ];-1 226 exports._unrefActive = exports.active = function(item) { -1 227 clearTimeout(item._idleTimeoutId); 269 228270 -1 function Node(enc, parent, name) {271 -1 const state = {};272 -1 this._baseState = state;273 -1274 -1 state.name = name;275 -1 state.enc = enc;276 -1277 -1 state.parent = parent || null;278 -1 state.children = null;279 -1280 -1 // State281 -1 state.tag = null;282 -1 state.args = null;283 -1 state.reverseArgs = null;284 -1 state.choice = null;285 -1 state.optional = false;286 -1 state.any = false;287 -1 state.obj = false;288 -1 state.use = null;289 -1 state.useDecoder = null;290 -1 state.key = null;291 -1 state['default'] = null;292 -1 state.explicit = null;293 -1 state.implicit = null;294 -1 state.contains = null;295 -1296 -1 // Should create new instance on each method297 -1 if (!state.parent) {298 -1 state.children = [];299 -1 this._wrap();-1 229 var msecs = item._idleTimeout; -1 230 if (msecs >= 0) { -1 231 item._idleTimeoutId = setTimeout(function onTimeout() { -1 232 if (item._onTimeout) -1 233 item._onTimeout(); -1 234 }, msecs); 300 235 }301 -1 }302 -1 module.exports = Node;303 -1304 -1 const stateProps = [305 -1 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',306 -1 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',307 -1 'implicit', 'contains'308 -1 ];309 -1310 -1 Node.prototype.clone = function clone() {311 -1 const state = this._baseState;312 -1 const cstate = {};313 -1 stateProps.forEach(function(prop) {314 -1 cstate[prop] = state[prop];315 -1 });316 -1 const res = new this.constructor(cstate.parent);317 -1 res._baseState = cstate;318 -1 return res;319 236 }; 320 237321 -1 Node.prototype._wrap = function wrap() {322 -1 const state = this._baseState;323 -1 methods.forEach(function(method) {324 -1 this[method] = function _wrappedMethod() {325 -1 const clone = new this.constructor(this);326 -1 state.children.push(clone);327 -1 return clone[method].apply(clone, arguments);328 -1 };329 -1 }, this);330 -1 };-1 238 // That's not how node.js implements it but the exposed api is the same. -1 239 exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { -1 240 var id = nextImmediateId++; -1 241 var args = arguments.length < 2 ? false : slice.call(arguments, 1); 331 242332 -1 Node.prototype._init = function init(body) {333 -1 const state = this._baseState;-1 243 immediateIds[id] = true; 334 244335 -1 assert(state.parent === null);336 -1 body.call(this);-1 245 nextTick(function onNextTick() { -1 246 if (immediateIds[id]) { -1 247 // fn.call() is faster so we optimize for the common use-case -1 248 // @see http://jsperf.com/call-apply-segu -1 249 if (args) { -1 250 fn.apply(null, args); -1 251 } else { -1 252 fn.call(null); -1 253 } -1 254 // Prevent ids from leaking -1 255 exports.clearImmediate(id); -1 256 } -1 257 }); 337 258338 -1 // Filter children339 -1 state.children = state.children.filter(function(child) {340 -1 return child._baseState.parent === this;341 -1 }, this);342 -1 assert.equal(state.children.length, 1, 'Root node can have only one child');-1 259 return id; 343 260 }; 344 261345 -1 Node.prototype._useArgs = function useArgs(args) {346 -1 const state = this._baseState;347 -1348 -1 // Filter children and args349 -1 const children = args.filter(function(arg) {350 -1 return arg instanceof this.constructor;351 -1 }, this);352 -1 args = args.filter(function(arg) {353 -1 return !(arg instanceof this.constructor);354 -1 }, this);355 -1356 -1 if (children.length !== 0) {357 -1 assert(state.children === null);358 -1 state.children = children;359 -1360 -1 // Replace parent to maintain backward link361 -1 children.forEach(function(child) {362 -1 child._baseState.parent = this;363 -1 }, this);364 -1 }365 -1 if (args.length !== 0) {366 -1 assert(state.args === null);367 -1 state.args = args;368 -1 state.reverseArgs = args.map(function(arg) {369 -1 if (typeof arg !== 'object' || arg.constructor !== Object)370 -1 return arg;371 -1372 -1 const res = {};373 -1 Object.keys(arg).forEach(function(key) {374 -1 if (key == (key | 0))375 -1 key |= 0;376 -1 const value = arg[key];377 -1 res[value] = key;378 -1 });379 -1 return res;380 -1 });381 -1 }-1 262 exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { -1 263 delete immediateIds[id]; 382 264 };383 -1384 -1 //385 -1 // Overrided methods-1 265 }).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate) -1 266 },{"process/browser.js":1,"timers":2}],3:[function(require,module,exports){ -1 267 // Copyright 2012 Google Inc. 386 268 //387 -1388 -1 overrided.forEach(function(method) {389 -1 Node.prototype[method] = function _overrided() {390 -1 const state = this._baseState;391 -1 throw new Error(method + ' not implemented for encoding: ' + state.enc);392 -1 };393 -1 });394 -1-1 269 // Licensed under the Apache License, Version 2.0 (the "License"); -1 270 // you may not use this file except in compliance with the License. -1 271 // You may obtain a copy of the License at 395 272 //396 -1 // Public methods-1 273 // http://www.apache.org/licenses/LICENSE-2.0 397 274 // -1 275 // Unless required by applicable law or agreed to in writing, software -1 276 // distributed under the License is distributed on an "AS IS" BASIS, -1 277 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -1 278 // See the License for the specific language governing permissions and -1 279 // limitations under the License. 398 280399 -1 tags.forEach(function(tag) {400 -1 Node.prototype[tag] = function _tagMethod() {401 -1 const state = this._baseState;402 -1 const args = Array.prototype.slice.call(arguments);403 -1404 -1 assert(state.tag === null);405 -1 state.tag = tag;-1 281 goog.require('axs.browserUtils'); -1 282 goog.require('axs.color'); -1 283 goog.require('axs.color.Color'); -1 284 goog.require('axs.constants'); -1 285 goog.require('axs.dom'); 406 286407 -1 this._useArgs(args);-1 287 goog.provide('axs.utils'); 408 288409 -1 return this;410 -1 };411 -1 });-1 289 /** -1 290 * @const -1 291 * @type {string} -1 292 */ -1 293 axs.utils.FOCUSABLE_ELEMENTS_SELECTOR = -1 294 'input:not([type=hidden]):not([disabled]),' + -1 295 'select:not([disabled]),' + -1 296 'textarea:not([disabled]),' + -1 297 'button:not([disabled]),' + -1 298 'a[href],' + -1 299 'iframe,' + -1 300 '[tabindex]'; 412 301413 -1 Node.prototype.use = function use(item) {414 -1 assert(item);415 -1 const state = this._baseState;-1 302 /** -1 303 * Elements that can have labels: https://html.spec.whatwg.org/multipage/forms.html#category-label -1 304 * @const -1 305 * @type {string} -1 306 */ -1 307 axs.utils.LABELABLE_ELEMENTS_SELECTOR = -1 308 'button,' + -1 309 'input:not([type=hidden]),' + -1 310 'keygen,' + -1 311 'meter,' + -1 312 'output,' + -1 313 'progress,' + -1 314 'select,' + -1 315 'textarea'; 416 316417 -1 assert(state.use === null);418 -1 state.use = item;419 317420 -1 return this;-1 318 /** -1 319 * @param {Element} element -1 320 * @return {boolean} -1 321 */ -1 322 axs.utils.elementIsTransparent = function(element) { -1 323 return element.style.opacity == '0'; 421 324 }; 422 325423 -1 Node.prototype.optional = function optional() {424 -1 const state = this._baseState;-1 326 /** -1 327 * @param {Element} element -1 328 * @return {boolean} -1 329 */ -1 330 axs.utils.elementHasZeroArea = function(element) { -1 331 var rect = element.getBoundingClientRect(); -1 332 var width = rect.right - rect.left; -1 333 var height = rect.top - rect.bottom; -1 334 if (!width || !height) -1 335 return true; -1 336 return false; -1 337 }; 425 338426 -1 state.optional = true;-1 339 /** -1 340 * @param {Element} element -1 341 * @return {boolean} -1 342 */ -1 343 axs.utils.elementIsOutsideScrollArea = function(element) { -1 344 var parent = axs.dom.parentElement(element); 427 345428 -1 return this;429 -1 };-1 346 var defaultView = element.ownerDocument.defaultView; -1 347 while (parent != defaultView.document.body) { -1 348 if (axs.utils.isClippedBy(element, parent)) -1 349 return true; 430 350431 -1 Node.prototype.def = function def(val) {432 -1 const state = this._baseState;-1 351 if (axs.utils.canScrollTo(element, parent) && !axs.utils.elementIsOutsideScrollArea(parent)) -1 352 return false; 433 353434 -1 assert(state['default'] === null);435 -1 state['default'] = val;436 -1 state.optional = true;-1 354 parent = axs.dom.parentElement(parent); -1 355 } 437 356438 -1 return this;-1 357 return !axs.utils.canScrollTo(element, defaultView.document.body); 439 358 }; 440 359441 -1 Node.prototype.explicit = function explicit(num) {442 -1 const state = this._baseState;443 -1444 -1 assert(state.explicit === null && state.implicit === null);445 -1 state.explicit = num;-1 360 /** -1 361 * Checks whether it's possible to scroll to the given element within the given container. -1 362 * Assumes that |container| is an ancestor of |element|. -1 363 * If |container| cannot be scrolled, returns True if the element is within its bounding client -1 364 * rect. -1 365 * @param {Element} element -1 366 * @param {Element} container -1 367 * @return {boolean} True iff it's possible to scroll to |element| within |container|. -1 368 */ -1 369 axs.utils.canScrollTo = function(element, container) { -1 370 var rect = element.getBoundingClientRect(); -1 371 var containerRect = container.getBoundingClientRect(); -1 372 if (container == container.ownerDocument.body) { -1 373 var absoluteTop = containerRect.top; -1 374 var absoluteLeft = containerRect.left; -1 375 } else { -1 376 var absoluteTop = containerRect.top - container.scrollTop; -1 377 var absoluteLeft = containerRect.left - container.scrollLeft; -1 378 } -1 379 var containerScrollArea = -1 380 { top: absoluteTop, -1 381 bottom: absoluteTop + container.scrollHeight, -1 382 left: absoluteLeft, -1 383 right: absoluteLeft + container.scrollWidth }; 446 384447 -1 return this;448 -1 };-1 385 if (rect.right < containerScrollArea.left || rect.bottom < containerScrollArea.top || -1 386 rect.left > containerScrollArea.right || rect.top > containerScrollArea.bottom) { -1 387 return false; -1 388 } 449 389450 -1 Node.prototype.implicit = function implicit(num) {451 -1 const state = this._baseState;-1 390 var defaultView = element.ownerDocument.defaultView; -1 391 var style = defaultView.getComputedStyle(container); 452 392453 -1 assert(state.explicit === null && state.implicit === null);454 -1 state.implicit = num;-1 393 if (rect.left > containerRect.right || rect.top > containerRect.bottom) { -1 394 return (style.overflow == 'scroll' || style.overflow == 'auto' || -1 395 container instanceof defaultView.HTMLBodyElement); -1 396 } 455 397456 -1 return this;-1 398 return true; 457 399 }; 458 400459 -1 Node.prototype.obj = function obj() {460 -1 const state = this._baseState;461 -1 const args = Array.prototype.slice.call(arguments);-1 401 /** -1 402 * Checks whether the given element is clipped by the given container. -1 403 * Assumes that |container| is an ancestor of |element|. -1 404 * @param {Element} element -1 405 * @param {Element} container -1 406 * @return {boolean} True iff |element| is clipped by |container|. -1 407 */ -1 408 axs.utils.isClippedBy = function(element, container) { -1 409 var rect = element.getBoundingClientRect(); -1 410 var containerRect = container.getBoundingClientRect(); -1 411 var containerTop = containerRect.top; -1 412 var containerLeft = containerRect.left; -1 413 var containerScrollArea = -1 414 { top: containerTop - container.scrollTop, -1 415 bottom: containerTop - container.scrollTop + container.scrollHeight, -1 416 left: containerLeft - container.scrollLeft, -1 417 right: containerLeft - container.scrollLeft + container.scrollWidth }; -1 418 -1 419 var defaultView = element.ownerDocument.defaultView; -1 420 var style = defaultView.getComputedStyle(container); 462 421463 -1 state.obj = true;-1 422 if ((rect.right < containerRect.left || rect.bottom < containerRect.top || -1 423 rect.left > containerRect.right || rect.top > containerRect.bottom) && -1 424 style.overflow == 'hidden') { -1 425 return true; -1 426 } 464 427465 -1 if (args.length !== 0)466 -1 this._useArgs(args);-1 428 if (rect.right < containerScrollArea.left || rect.bottom < containerScrollArea.top) -1 429 return (style.overflow != 'visible'); 467 430468 -1 return this;-1 431 return false; 469 432 }; 470 433471 -1 Node.prototype.key = function key(newKey) {472 -1 const state = this._baseState;473 -1474 -1 assert(state.key === null);475 -1 state.key = newKey;-1 434 /** -1 435 * @param {Node} ancestor A potential ancestor of |node|. -1 436 * @param {Node} node -1 437 * @return {boolean} true if |ancestor| is an ancestor of |node| (including -1 438 * |ancestor| === |node|). -1 439 */ -1 440 axs.utils.isAncestor = function(ancestor, node) { -1 441 if (node == null) -1 442 return false; -1 443 if (node === ancestor) -1 444 return true; 476 445477 -1 return this;-1 446 var parentNode = axs.dom.composedParentNode(node); -1 447 return axs.utils.isAncestor(ancestor, parentNode); 478 448 }; 479 449480 -1 Node.prototype.any = function any() {481 -1 const state = this._baseState;-1 450 /** -1 451 * @param {Element} element -1 452 * @return {Array.<Element>} An array of any non-transparent elements which -1 453 * overlap the given element. -1 454 */ -1 455 axs.utils.overlappingElements = function(element) { -1 456 if (axs.utils.elementHasZeroArea(element)) -1 457 return null; 482 458483 -1 state.any = true;-1 459 var overlappingElements = []; -1 460 var clientRects = element.getClientRects(); -1 461 for (var i = 0; i < clientRects.length; i++) { -1 462 var rect = clientRects[i]; -1 463 var center_x = (rect.left + rect.right) / 2; -1 464 var center_y = (rect.top + rect.bottom) / 2; -1 465 var elementAtPoint = document.elementFromPoint(center_x, center_y); 484 466485 -1 return this;486 -1 };-1 467 if (elementAtPoint == null || elementAtPoint == element || -1 468 axs.utils.isAncestor(elementAtPoint, element) || -1 469 axs.utils.isAncestor(element, elementAtPoint)) { -1 470 continue; -1 471 } 487 472488 -1 Node.prototype.choice = function choice(obj) {489 -1 const state = this._baseState;-1 473 var overlappingElementStyle = window.getComputedStyle(elementAtPoint, null); -1 474 if (!overlappingElementStyle) -1 475 continue; 490 476491 -1 assert(state.choice === null);492 -1 state.choice = obj;493 -1 this._useArgs(Object.keys(obj).map(function(key) {494 -1 return obj[key];495 -1 }));-1 477 var overlappingElementBg = axs.utils.getBgColor(overlappingElementStyle, -1 478 elementAtPoint); -1 479 if (overlappingElementBg && overlappingElementBg.alpha > 0 && -1 480 overlappingElements.indexOf(elementAtPoint) < 0) { -1 481 overlappingElements.push(elementAtPoint); -1 482 } -1 483 } 496 484497 -1 return this;-1 485 return overlappingElements; 498 486 }; 499 487500 -1 Node.prototype.contains = function contains(item) {501 -1 const state = this._baseState;-1 488 /** -1 489 * @param {Element} element -1 490 * @return {boolean} -1 491 */ -1 492 axs.utils.elementIsHtmlControl = function(element) { -1 493 var defaultView = element.ownerDocument.defaultView; 502 494503 -1 assert(state.use === null);504 -1 state.contains = item;-1 495 // HTML control -1 496 if (element instanceof defaultView.HTMLButtonElement) -1 497 return true; -1 498 if (element instanceof defaultView.HTMLInputElement) -1 499 return true; -1 500 if (element instanceof defaultView.HTMLSelectElement) -1 501 return true; -1 502 if (element instanceof defaultView.HTMLTextAreaElement) -1 503 return true; 505 504506 -1 return this;-1 505 return false; 507 506 }; 508 507509 -1 //510 -1 // Decoding511 -1 //512 -1513 -1 Node.prototype._decode = function decode(input, options) {514 -1 const state = this._baseState;515 -1516 -1 // Decode root node517 -1 if (state.parent === null)518 -1 return input.wrapResult(state.children[0]._decode(input, options));519 -1520 -1 let result = state['default'];521 -1 let present = true;522 -1523 -1 let prevKey = null;524 -1 if (state.key !== null)525 -1 prevKey = input.enterKey(state.key);526 -1527 -1 // Check if tag is there528 -1 if (state.optional) {529 -1 let tag = null;530 -1 if (state.explicit !== null)531 -1 tag = state.explicit;532 -1 else if (state.implicit !== null)533 -1 tag = state.implicit;534 -1 else if (state.tag !== null)535 -1 tag = state.tag;536 -1537 -1 if (tag === null && !state.any) {538 -1 // Trial and Error539 -1 const save = input.save();540 -1 try {541 -1 if (state.choice === null)542 -1 this._decodeGeneric(state.tag, input, options);543 -1 else544 -1 this._decodeChoice(input, options);545 -1 present = true;546 -1 } catch (e) {547 -1 present = false;548 -1 }549 -1 input.restore(save);550 -1 } else {551 -1 present = this._peekTag(input, tag, state.any);552 -1553 -1 if (input.isError(present))554 -1 return present;-1 508 /** -1 509 * @param {Element} element -1 510 * @return {boolean} -1 511 */ -1 512 axs.utils.elementIsAriaWidget = function(element) { -1 513 if (element.hasAttribute('role')) { -1 514 var roleValue = element.getAttribute('role'); -1 515 // TODO is this correct? -1 516 if (roleValue) { -1 517 var role = axs.constants.ARIA_ROLES[roleValue]; -1 518 if (role && 'widget' in role['allParentRolesSet']) -1 519 return true; -1 520 } 555 521 }556 -1 }557 -1558 -1 // Push object on stack559 -1 let prevObj;560 -1 if (state.obj && present)561 -1 prevObj = input.enterObject();562 -1563 -1 if (present) {564 -1 // Unwrap explicit values565 -1 if (state.explicit !== null) {566 -1 const explicit = this._decodeTag(input, state.explicit);567 -1 if (input.isError(explicit))568 -1 return explicit;569 -1 input = explicit;570 -1 }571 -1572 -1 const start = input.offset;573 -1574 -1 // Unwrap implicit and normal values575 -1 if (state.use === null && state.choice === null) {576 -1 let save;577 -1 if (state.any)578 -1 save = input.save();579 -1 const body = this._decodeTag(580 -1 input,581 -1 state.implicit !== null ? state.implicit : state.tag,582 -1 state.any583 -1 );584 -1 if (input.isError(body))585 -1 return body;-1 522 return false; -1 523 }; 586 524587 -1 if (state.any)588 -1 result = input.raw(save);589 -1 else590 -1 input = body;591 -1 }-1 525 /** -1 526 * @param {Element} element -1 527 * @return {boolean} -1 528 */ -1 529 axs.utils.elementIsVisible = function(element) { -1 530 if (axs.utils.elementIsTransparent(element)) -1 531 return false; -1 532 if (axs.utils.elementHasZeroArea(element)) -1 533 return false; -1 534 if (axs.utils.elementIsOutsideScrollArea(element)) -1 535 return false; 592 536593 -1 if (options && options.track && state.tag !== null)594 -1 options.track(input.path(), start, input.length, 'tagged');-1 537 var overlappingElements = axs.utils.overlappingElements(element); -1 538 if (overlappingElements.length) -1 539 return false; 595 540596 -1 if (options && options.track && state.tag !== null)597 -1 options.track(input.path(), input.offset, input.length, 'content');-1 541 return true; -1 542 }; 598 543599 -1 // Select proper method for tag600 -1 if (state.any) {601 -1 // no-op602 -1 } else if (state.choice === null) {603 -1 result = this._decodeGeneric(state.tag, input, options);604 -1 } else {605 -1 result = this._decodeChoice(input, options);-1 544 /** -1 545 * @param {CSSStyleDeclaration} style -1 546 * @return {boolean} -1 547 */ -1 548 axs.utils.isLargeFont = function(style) { -1 549 var fontSize = style.fontSize; -1 550 var bold = style.fontWeight == 'bold'; -1 551 var matches = fontSize.match(/(\d+)px/); -1 552 if (matches) { -1 553 var fontSizePx = parseInt(matches[1], 10); -1 554 var bodyStyle = window.getComputedStyle(document.body, null); -1 555 var bodyFontSize = bodyStyle.fontSize; -1 556 matches = bodyFontSize.match(/(\d+)px/); -1 557 if (matches) { -1 558 var bodyFontSizePx = parseInt(matches[1], 10); -1 559 var boldLarge = bodyFontSizePx * 1.2; -1 560 var large = bodyFontSizePx * 1.5; -1 561 } else { -1 562 var boldLarge = 19.2; -1 563 var large = 24; -1 564 } -1 565 return (bold && fontSizePx >= boldLarge || fontSizePx >= large); 606 566 }607 -1608 -1 if (input.isError(result))609 -1 return result;610 -1611 -1 // Decode children612 -1 if (!state.any && state.choice === null && state.children !== null) {613 -1 state.children.forEach(function decodeChildren(child) {614 -1 // NOTE: We are ignoring errors here, to let parser continue with other615 -1 // parts of encoded data616 -1 child._decode(input, options);617 -1 });-1 567 matches = fontSize.match(/(\d+)em/); -1 568 if (matches) { -1 569 var fontSizeEm = parseInt(matches[1], 10); -1 570 if (bold && fontSizeEm >= 1.2 || fontSizeEm >= 1.5) -1 571 return true; -1 572 return false; 618 573 }619 -1620 -1 // Decode contained/encoded by schema, only in bit or octet strings621 -1 if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {622 -1 const data = new DecoderBuffer(result);623 -1 result = this._getUse(state.contains, input._reporterState.obj)624 -1 ._decode(data, options);-1 574 matches = fontSize.match(/(\d+)%/); -1 575 if (matches) { -1 576 var fontSizePercent = parseInt(matches[1], 10); -1 577 if (bold && fontSizePercent >= 120 || fontSizePercent >= 150) -1 578 return true; -1 579 return false; 625 580 }626 -1 }627 -1628 -1 // Pop object629 -1 if (state.obj && present)630 -1 result = input.leaveObject(prevObj);631 -1632 -1 // Set key633 -1 if (state.key !== null && (result !== null || present === true))634 -1 input.leaveKey(prevKey, state.key, result);635 -1 else if (prevKey !== null)636 -1 input.exitKey(prevKey);637 -1638 -1 return result;639 -1 };640 -1641 -1 Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {642 -1 const state = this._baseState;643 -1644 -1 if (tag === 'seq' || tag === 'set')645 -1 return null;646 -1 if (tag === 'seqof' || tag === 'setof')647 -1 return this._decodeList(input, tag, state.args[0], options);648 -1 else if (/str$/.test(tag))649 -1 return this._decodeStr(input, tag, options);650 -1 else if (tag === 'objid' && state.args)651 -1 return this._decodeObjid(input, state.args[0], state.args[1], options);652 -1 else if (tag === 'objid')653 -1 return this._decodeObjid(input, null, null, options);654 -1 else if (tag === 'gentime' || tag === 'utctime')655 -1 return this._decodeTime(input, tag, options);656 -1 else if (tag === 'null_')657 -1 return this._decodeNull(input, options);658 -1 else if (tag === 'bool')659 -1 return this._decodeBool(input, options);660 -1 else if (tag === 'objDesc')661 -1 return this._decodeStr(input, tag, options);662 -1 else if (tag === 'int' || tag === 'enum')663 -1 return this._decodeInt(input, state.args && state.args[0], options);664 -1665 -1 if (state.use !== null) {666 -1 return this._getUse(state.use, input._reporterState.obj)667 -1 ._decode(input, options);668 -1 } else {669 -1 return input.error('unknown tag: ' + tag);670 -1 }671 -1 };672 -1673 -1 Node.prototype._getUse = function _getUse(entity, obj) {674 -1675 -1 const state = this._baseState;676 -1 // Create altered use decoder if implicit is set677 -1 state.useDecoder = this._use(entity, obj);678 -1 assert(state.useDecoder._baseState.parent === null);679 -1 state.useDecoder = state.useDecoder._baseState.children[0];680 -1 if (state.implicit !== state.useDecoder._baseState.implicit) {681 -1 state.useDecoder = state.useDecoder.clone();682 -1 state.useDecoder._baseState.implicit = state.implicit;683 -1 }684 -1 return state.useDecoder;685 -1 };686 -1687 -1 Node.prototype._decodeChoice = function decodeChoice(input, options) {688 -1 const state = this._baseState;689 -1 let result = null;690 -1 let match = false;691 -1692 -1 Object.keys(state.choice).some(function(key) {693 -1 const save = input.save();694 -1 const node = state.choice[key];695 -1 try {696 -1 const value = node._decode(input, options);697 -1 if (input.isError(value))-1 581 matches = fontSize.match(/(\d+)pt/); -1 582 if (matches) { -1 583 var fontSizePt = parseInt(matches[1], 10); -1 584 if (bold && fontSizePt >= 14 || fontSizePt >= 18) -1 585 return true; 698 586 return false;699 -1700 -1 result = { type: key, value: value };701 -1 match = true;702 -1 } catch (e) {703 -1 input.restore(save);704 -1 return false;705 587 }706 -1 return true;707 -1 }, this);708 -1709 -1 if (!match)710 -1 return input.error('Choice not matched');711 -1712 -1 return result;713 -1 };714 -1715 -1 //716 -1 // Encoding717 -1 //718 -1719 -1 Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {720 -1 return new EncoderBuffer(data, this.reporter);-1 588 return false; 721 589 }; 722 590723 -1 Node.prototype._encode = function encode(data, reporter, parent) {724 -1 const state = this._baseState;725 -1 if (state['default'] !== null && state['default'] === data)726 -1 return;-1 591 /** -1 592 * @param {CSSStyleDeclaration} style -1 593 * @param {Element} element -1 594 * @return {?axs.color.Color} -1 595 */ -1 596 axs.utils.getBgColor = function(style, element) { -1 597 var bgColorString = style.backgroundColor; -1 598 var bgColor = axs.color.parseColor(bgColorString); -1 599 if (!bgColor) -1 600 return null; 727 601728 -1 const result = this._encodeValue(data, reporter, parent);729 -1 if (result === undefined)730 -1 return;-1 602 if (style.opacity < 1) -1 603 bgColor.alpha = bgColor.alpha * style.opacity; 731 604732 -1 if (this._skipDefault(result, reporter, parent))733 -1 return;-1 605 if (bgColor.alpha < 1) { -1 606 var parentBg = axs.utils.getParentBgColor(element); -1 607 if (parentBg == null) -1 608 return null; 734 609735 -1 return result;-1 610 bgColor = axs.color.flattenColors(bgColor, parentBg); -1 611 } -1 612 return bgColor; 736 613 }; 737 614738 -1 Node.prototype._encodeValue = function encode(data, reporter, parent) {739 -1 const state = this._baseState;-1 615 /** -1 616 * Gets the effective background color of the parent of |element|. -1 617 * @param {Element} element -1 618 * @return {?axs.color.Color} -1 619 */ -1 620 axs.utils.getParentBgColor = function(element) { -1 621 /** @type {Element} */ var parent = element; -1 622 var bgStack = []; -1 623 var foundSolidColor = null; -1 624 while ((parent = axs.dom.parentElement(parent))) { -1 625 var computedStyle = window.getComputedStyle(parent, null); -1 626 if (!computedStyle) -1 627 continue; 740 628741 -1 // Decode root node742 -1 if (state.parent === null)743 -1 return state.children[0]._encode(data, reporter || new Reporter());-1 629 var parentBg = axs.color.parseColor(computedStyle.backgroundColor); -1 630 if (!parentBg) -1 631 continue; 744 632745 -1 let result = null;-1 633 if (computedStyle.opacity < 1) -1 634 parentBg.alpha = parentBg.alpha * computedStyle.opacity; 746 635747 -1 // Set reporter to share it with a child class748 -1 this.reporter = reporter;-1 636 if (parentBg.alpha == 0) -1 637 continue; 749 638750 -1 // Check if data is there751 -1 if (state.optional && data === undefined) {752 -1 if (state['default'] !== null)753 -1 data = state['default'];754 -1 else755 -1 return;756 -1 }-1 639 bgStack.push(parentBg); 757 640758 -1 // Encode children first759 -1 let content = null;760 -1 let primitive = false;761 -1 if (state.any) {762 -1 // Anything that was given is translated to buffer763 -1 result = this._createEncoderBuffer(data);764 -1 } else if (state.choice) {765 -1 result = this._encodeChoice(data, reporter);766 -1 } else if (state.contains) {767 -1 content = this._getUse(state.contains, parent)._encode(data, reporter);768 -1 primitive = true;769 -1 } else if (state.children) {770 -1 content = state.children.map(function(child) {771 -1 if (child._baseState.tag === 'null_')772 -1 return child._encode(null, reporter, data);773 -1774 -1 if (child._baseState.key === null)775 -1 return reporter.error('Child should have a key');776 -1 const prevKey = reporter.enterKey(child._baseState.key);777 -1778 -1 if (typeof data !== 'object')779 -1 return reporter.error('Child expected, but input is not object');780 -1781 -1 const res = child._encode(data[child._baseState.key], reporter, data);782 -1 reporter.leaveKey(prevKey);783 -1784 -1 return res;785 -1 }, this).filter(function(child) {786 -1 return child;787 -1 });788 -1 content = this._createEncoderBuffer(content);789 -1 } else {790 -1 if (state.tag === 'seqof' || state.tag === 'setof') {791 -1 // TODO(indutny): this should be thrown on DSL level792 -1 if (!(state.args && state.args.length === 1))793 -1 return reporter.error('Too many args for : ' + state.tag);794 -1795 -1 if (!Array.isArray(data))796 -1 return reporter.error('seqof/setof, but data is not Array');797 -1798 -1 const child = this.clone();799 -1 child._baseState.implicit = null;800 -1 content = this._createEncoderBuffer(data.map(function(item) {801 -1 const state = this._baseState;802 -1803 -1 return this._getUse(state.args[0], data)._encode(item, reporter);804 -1 }, child));805 -1 } else if (state.use !== null) {806 -1 result = this._getUse(state.use, parent)._encode(data, reporter);807 -1 } else {808 -1 content = this._encodePrimitive(state.tag, data);809 -1 primitive = true;-1 641 if (parentBg.alpha == 1) { -1 642 foundSolidColor = true; -1 643 break; -1 644 } 810 645 }811 -1 }812 646813 -1 // Encode data itself814 -1 if (!state.any && state.choice === null) {815 -1 const tag = state.implicit !== null ? state.implicit : state.tag;816 -1 const cls = state.implicit === null ? 'universal' : 'context';-1 647 if (!foundSolidColor) -1 648 bgStack.push(new axs.color.Color(255, 255, 255, 1)); 817 649818 -1 if (tag === null) {819 -1 if (state.use === null)820 -1 reporter.error('Tag could be omitted only for .use()');821 -1 } else {822 -1 if (state.use === null)823 -1 result = this._encodeComposite(tag, primitive, cls, content);-1 650 var bg = bgStack.pop(); -1 651 while (bgStack.length) { -1 652 var fg = bgStack.pop(); -1 653 bg = axs.color.flattenColors(fg, bg); 824 654 }825 -1 }826 -1827 -1 // Wrap in explicit828 -1 if (state.explicit !== null)829 -1 result = this._encodeComposite(state.explicit, false, 'context', result);830 -1831 -1 return result;832 -1 };833 -1834 -1 Node.prototype._encodeChoice = function encodeChoice(data, reporter) {835 -1 const state = this._baseState;836 -1837 -1 const node = state.choice[data.type];838 -1 if (!node) {839 -1 assert(840 -1 false,841 -1 data.type + ' not found in ' +842 -1 JSON.stringify(Object.keys(state.choice)));843 -1 }844 -1 return node._encode(data.value, reporter);845 -1 };846 -1847 -1 Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {848 -1 const state = this._baseState;849 -1850 -1 if (/str$/.test(tag))851 -1 return this._encodeStr(data, tag);852 -1 else if (tag === 'objid' && state.args)853 -1 return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);854 -1 else if (tag === 'objid')855 -1 return this._encodeObjid(data, null, null);856 -1 else if (tag === 'gentime' || tag === 'utctime')857 -1 return this._encodeTime(data, tag);858 -1 else if (tag === 'null_')859 -1 return this._encodeNull();860 -1 else if (tag === 'int' || tag === 'enum')861 -1 return this._encodeInt(data, state.args && state.reverseArgs[0]);862 -1 else if (tag === 'bool')863 -1 return this._encodeBool(data);864 -1 else if (tag === 'objDesc')865 -1 return this._encodeStr(data, tag);866 -1 else867 -1 throw new Error('Unsupported tag: ' + tag);868 -1 };869 -1870 -1 Node.prototype._isNumstr = function isNumstr(str) {871 -1 return /^[0-9 ]*$/.test(str);872 -1 };873 -1874 -1 Node.prototype._isPrintstr = function isPrintstr(str) {875 -1 return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str);876 -1 };877 -1878 -1 },{"../base/buffer":3,"../base/reporter":6,"minimalistic-assert":136}],6:[function(require,module,exports){879 -1 'use strict';880 -1881 -1 const inherits = require('inherits');882 -1883 -1 function Reporter(options) {884 -1 this._reporterState = {885 -1 obj: null,886 -1 path: [],887 -1 options: options || {},888 -1 errors: []889 -1 };890 -1 }891 -1 exports.Reporter = Reporter;892 -1893 -1 Reporter.prototype.isError = function isError(obj) {894 -1 return obj instanceof ReporterError;-1 655 return bg; 895 656 }; 896 657897 -1 Reporter.prototype.save = function save() {898 -1 const state = this._reporterState;899 -1900 -1 return { obj: state.obj, pathLen: state.path.length };901 -1 };-1 658 /** -1 659 * @param {CSSStyleDeclaration} style -1 660 * @param {Element} element -1 661 * @param {axs.color.Color} bgColor The background color, which may come from -1 662 * another element (such as a parent element), for flattening into the -1 663 * foreground color. -1 664 * @return {?axs.color.Color} -1 665 */ -1 666 axs.utils.getFgColor = function(style, element, bgColor) { -1 667 var fgColorString = style.color; -1 668 var fgColor = axs.color.parseColor(fgColorString); -1 669 if (!fgColor) -1 670 return null; 902 671903 -1 Reporter.prototype.restore = function restore(data) {904 -1 const state = this._reporterState;-1 672 if (fgColor.alpha < 1) -1 673 fgColor = axs.color.flattenColors(fgColor, bgColor); 905 674906 -1 state.obj = data.obj;907 -1 state.path = state.path.slice(0, data.pathLen);908 -1 };-1 675 if (style.opacity < 1) { -1 676 var parentBg = axs.utils.getParentBgColor(element); -1 677 fgColor.alpha = fgColor.alpha * style.opacity; -1 678 fgColor = axs.color.flattenColors(fgColor, parentBg); -1 679 } 909 680910 -1 Reporter.prototype.enterKey = function enterKey(key) {911 -1 return this._reporterState.path.push(key);-1 681 return fgColor; 912 682 }; 913 683914 -1 Reporter.prototype.exitKey = function exitKey(index) {915 -1 const state = this._reporterState;916 -1917 -1 state.path = state.path.slice(0, index - 1);-1 684 /** -1 685 * @param {Element} element -1 686 * @return {?number} -1 687 */ -1 688 axs.utils.getContrastRatioForElement = function(element) { -1 689 var style = window.getComputedStyle(element, null); -1 690 return axs.utils.getContrastRatioForElementWithComputedStyle(style, element); 918 691 }; 919 692920 -1 Reporter.prototype.leaveKey = function leaveKey(index, key, value) {921 -1 const state = this._reporterState;922 -1923 -1 this.exitKey(index);924 -1 if (state.obj !== null)925 -1 state.obj[key] = value;926 -1 };-1 693 /** -1 694 * @param {CSSStyleDeclaration} style -1 695 * @param {Element} element -1 696 * @return {?number} -1 697 */ -1 698 axs.utils.getContrastRatioForElementWithComputedStyle = function(style, element) { -1 699 if (axs.utils.isElementHidden(element)) -1 700 return null; 927 701928 -1 Reporter.prototype.path = function path() {929 -1 return this._reporterState.path.join('/');930 -1 };-1 702 var bgColor = axs.utils.getBgColor(style, element); -1 703 if (!bgColor) -1 704 return null; 931 705932 -1 Reporter.prototype.enterObject = function enterObject() {933 -1 const state = this._reporterState;-1 706 var fgColor = axs.utils.getFgColor(style, element, bgColor); -1 707 if (!fgColor) -1 708 return null; 934 709935 -1 const prev = state.obj;936 -1 state.obj = {};937 -1 return prev;-1 710 return axs.color.calculateContrastRatio(fgColor, bgColor); 938 711 }; 939 712940 -1 Reporter.prototype.leaveObject = function leaveObject(prev) {941 -1 const state = this._reporterState;-1 713 /** -1 714 * @param {Element} element -1 715 * @return {boolean} -1 716 */ -1 717 axs.utils.isNativeTextElement = function(element) { -1 718 var tagName = element.tagName.toLowerCase(); -1 719 var type = element.type ? element.type.toLowerCase() : ''; -1 720 if (tagName == 'textarea') -1 721 return true; -1 722 if (tagName != 'input') -1 723 return false; 942 724943 -1 const now = state.obj;944 -1 state.obj = prev;945 -1 return now;-1 725 switch (type) { -1 726 case 'email': -1 727 case 'number': -1 728 case 'password': -1 729 case 'search': -1 730 case 'text': -1 731 case 'tel': -1 732 case 'url': -1 733 case '': -1 734 return true; -1 735 default: -1 736 return false; -1 737 } 946 738 }; 947 739948 -1 Reporter.prototype.error = function error(msg) {949 -1 let err;950 -1 const state = this._reporterState;951 -1952 -1 const inherited = msg instanceof ReporterError;953 -1 if (inherited) {954 -1 err = msg;955 -1 } else {956 -1 err = new ReporterError(state.path.map(function(elem) {957 -1 return '[' + JSON.stringify(elem) + ']';958 -1 }).join(''), msg.message || msg, msg.stack);959 -1 }960 -1961 -1 if (!state.options.partial)962 -1 throw err;963 -1964 -1 if (!inherited)965 -1 state.errors.push(err);966 -1967 -1 return err;-1 740 /** -1 741 * @param {number} contrastRatio -1 742 * @param {CSSStyleDeclaration} style -1 743 * @param {boolean=} opt_strict Whether to use AA (false) or AAA (true) level -1 744 * @return {boolean} -1 745 */ -1 746 axs.utils.isLowContrast = function(contrastRatio, style, opt_strict) { -1 747 // Round to nearest 0.1 -1 748 var roundedContrastRatio = (Math.round(contrastRatio * 10) / 10); -1 749 if (!opt_strict) { -1 750 return roundedContrastRatio < 3.0 || -1 751 (!axs.utils.isLargeFont(style) && roundedContrastRatio < 4.5); -1 752 } else { -1 753 return roundedContrastRatio < 4.5 || -1 754 (!axs.utils.isLargeFont(style) && roundedContrastRatio < 7.0); -1 755 } 968 756 }; 969 757970 -1 Reporter.prototype.wrapResult = function wrapResult(result) {971 -1 const state = this._reporterState;972 -1 if (!state.options.partial)973 -1 return result;-1 758 /** -1 759 * @param {Element} element -1 760 * @return {boolean} -1 761 */ -1 762 axs.utils.hasLabel = function(element) { -1 763 var tagName = element.tagName.toLowerCase(); -1 764 var type = element.type ? element.type.toLowerCase() : ''; 974 765975 -1 return {976 -1 result: this.isError(result) ? null : result,977 -1 errors: state.errors978 -1 };979 -1 };-1 766 if (element.hasAttribute('aria-label')) -1 767 return true; -1 768 if (element.hasAttribute('title')) -1 769 return true; -1 770 if (tagName == 'img' && element.hasAttribute('alt')) -1 771 return true; -1 772 if (tagName == 'input' && type == 'image' && element.hasAttribute('alt')) -1 773 return true; -1 774 if (tagName == 'input' && (type == 'submit' || type == 'reset')) -1 775 return true; 980 776981 -1 function ReporterError(path, msg) {982 -1 this.path = path;983 -1 this.rethrow(msg);984 -1 }985 -1 inherits(ReporterError, Error);-1 777 // There's a separate audit that makes sure this points to an actual element or elements. -1 778 if (element.hasAttribute('aria-labelledby')) -1 779 return true; 986 780987 -1 ReporterError.prototype.rethrow = function rethrow(msg) {988 -1 this.message = msg + ' at: ' + (this.path || '(shallow)');989 -1 if (Error.captureStackTrace)990 -1 Error.captureStackTrace(this, ReporterError);-1 781 if (element.hasAttribute('id')) { -1 782 var labelsFor = document.querySelectorAll('label[for="' + element.id + '"]'); -1 783 if (labelsFor.length > 0) -1 784 return true; -1 785 } 991 786992 -1 if (!this.stack) {993 -1 try {994 -1 // IE only adds stack when thrown995 -1 throw new Error(this.message);996 -1 } catch (e) {997 -1 this.stack = e.stack;-1 787 var parent = axs.dom.parentElement(element); -1 788 while (parent) { -1 789 if (parent.tagName.toLowerCase() == 'label') { -1 790 var parentLabel = /** HTMLLabelElement */ parent; -1 791 if (parentLabel.control == element) -1 792 return true; -1 793 } -1 794 parent = axs.dom.parentElement(parent); 998 795 }999 -1 }1000 -1 return this;-1 796 return false; 1001 797 }; 1002 7981003 -1 },{"inherits":132}],7:[function(require,module,exports){1004 -1 'use strict';1005 -11006 -1 // Helper1007 -1 function reverse(map) {1008 -1 const res = {};1009 -11010 -1 Object.keys(map).forEach(function(key) {1011 -1 // Convert key to integer if it is stringified1012 -1 if ((key | 0) == key)1013 -1 key = key | 0;1014 -11015 -1 const value = map[key];1016 -1 res[value] = key;1017 -1 });1018 -11019 -1 return res;1020 -1 }1021 -11022 -1 exports.tagClass = {1023 -1 0: 'universal',1024 -1 1: 'application',1025 -1 2: 'context',1026 -1 3: 'private'1027 -1 };1028 -1 exports.tagClassByName = reverse(exports.tagClass);1029 -11030 -1 exports.tag = {1031 -1 0x00: 'end',1032 -1 0x01: 'bool',1033 -1 0x02: 'int',1034 -1 0x03: 'bitstr',1035 -1 0x04: 'octstr',1036 -1 0x05: 'null_',1037 -1 0x06: 'objid',1038 -1 0x07: 'objDesc',1039 -1 0x08: 'external',1040 -1 0x09: 'real',1041 -1 0x0a: 'enum',1042 -1 0x0b: 'embed',1043 -1 0x0c: 'utf8str',1044 -1 0x0d: 'relativeOid',1045 -1 0x10: 'seq',1046 -1 0x11: 'set',1047 -1 0x12: 'numstr',1048 -1 0x13: 'printstr',1049 -1 0x14: 't61str',1050 -1 0x15: 'videostr',1051 -1 0x16: 'ia5str',1052 -1 0x17: 'utctime',1053 -1 0x18: 'gentime',1054 -1 0x19: 'graphstr',1055 -1 0x1a: 'iso646str',1056 -1 0x1b: 'genstr',1057 -1 0x1c: 'unistr',1058 -1 0x1d: 'charstr',1059 -1 0x1e: 'bmpstr'-1 799 /** -1 800 * Determine if this element natively supports being disabled (i.e. via the `disabled` attribute. -1 801 * Disabled here means that the element should be considered disabled according to specification. -1 802 * This element may or may not be effectively disabled in practice as this is dependent on implementation. -1 803 * -1 804 * @param {Element} element An element to check. -1 805 * @return {boolean} true If the element supports being natively disabled. -1 806 */ -1 807 axs.utils.isNativelyDisableable = function(element) { -1 808 var tagName = element.tagName.toUpperCase(); -1 809 return (tagName in axs.constants.NATIVELY_DISABLEABLE); 1060 810 };1061 -1 exports.tagByName = reverse(exports.tag);1062 -11063 -1 },{}],8:[function(require,module,exports){1064 -1 'use strict';1065 -11066 -1 const constants = exports;1067 -11068 -1 // Helper1069 -1 constants._reverse = function reverse(map) {1070 -1 const res = {};1071 -11072 -1 Object.keys(map).forEach(function(key) {1073 -1 // Convert key to integer if it is stringified1074 -1 if ((key | 0) == key)1075 -1 key = key | 0;1076 8111077 -1 const value = map[key];1078 -1 res[value] = key;1079 -1 });1080 -11081 -1 return res;-1 812 /** -1 813 * Determine if this element is disabled directly or indirectly by a disabled ancestor. -1 814 * Disabled here means that the element should be considered disabled according to specification. -1 815 * This element may or may not be effectively disabled in practice as this is dependent on implementation. -1 816 * -1 817 * @param {Element} element An element to check. -1 818 * @param {boolean=} ignoreAncestors If true do not check for disabled ancestors. -1 819 * @return {boolean} true if the element or one of its ancestors is disabled. -1 820 */ -1 821 axs.utils.isElementDisabled = function(element, ignoreAncestors) { -1 822 var selector = ignoreAncestors ? '[aria-disabled=true]' : '[aria-disabled=true], [aria-disabled=true] *'; -1 823 if (axs.browserUtils.matchSelector(element, selector)) { -1 824 return true; -1 825 } -1 826 if (!axs.utils.isNativelyDisableable(element) || -1 827 axs.browserUtils.matchSelector(element, 'fieldset>legend:first-of-type *')) { -1 828 return false; -1 829 } -1 830 for (var next = element; next !== null; next = axs.dom.parentElement(next)) { -1 831 if (next.hasAttribute('disabled')) { -1 832 return true; -1 833 } -1 834 if (ignoreAncestors) { -1 835 return false; -1 836 } -1 837 } -1 838 return false; 1082 839 }; 1083 8401084 -1 constants.der = require('./der');1085 -11086 -1 },{"./der":7}],9:[function(require,module,exports){1087 -1 'use strict';1088 -11089 -1 const inherits = require('inherits');1090 -11091 -1 const bignum = require('bn.js');1092 -1 const DecoderBuffer = require('../base/buffer').DecoderBuffer;1093 -1 const Node = require('../base/node');1094 -11095 -1 // Import DER constants1096 -1 const der = require('../constants/der');1097 -11098 -1 function DERDecoder(entity) {1099 -1 this.enc = 'der';1100 -1 this.name = entity.name;1101 -1 this.entity = entity;1102 -11103 -1 // Construct base tree1104 -1 this.tree = new DERNode();1105 -1 this.tree._init(entity.body);1106 -1 }1107 -1 module.exports = DERDecoder;1108 -11109 -1 DERDecoder.prototype.decode = function decode(data, options) {1110 -1 if (!DecoderBuffer.isDecoderBuffer(data)) {1111 -1 data = new DecoderBuffer(data, options);1112 -1 }-1 841 /** -1 842 * @param {Element} element An element to check. -1 843 * @return {boolean} True if the element is hidden from accessibility. -1 844 */ -1 845 axs.utils.isElementHidden = function(element) { -1 846 if (!(element instanceof element.ownerDocument.defaultView.HTMLElement)) -1 847 return false; 1113 8481114 -1 return this.tree._decode(data, options);1115 -1 };-1 849 if (element.hasAttribute('chromevoxignoreariahidden')) -1 850 var chromevoxignoreariahidden = true; 1116 8511117 -1 // Tree methods-1 852 var style = window.getComputedStyle(element, null); -1 853 if (style.display == 'none' || style.visibility == 'hidden') -1 854 return true; 1118 8551119 -1 function DERNode(parent) {1120 -1 Node.call(this, 'der', parent);1121 -1 }1122 -1 inherits(DERNode, Node);-1 856 if (element.hasAttribute('aria-hidden') && -1 857 element.getAttribute('aria-hidden').toLowerCase() == 'true') { -1 858 return !chromevoxignoreariahidden; -1 859 } 1123 8601124 -1 DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {1125 -1 if (buffer.isEmpty())1126 861 return false;1127 -11128 -1 const state = buffer.save();1129 -1 const decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');1130 -1 if (buffer.isError(decodedTag))1131 -1 return decodedTag;1132 -11133 -1 buffer.restore(state);1134 -11135 -1 return decodedTag.tag === tag || decodedTag.tagStr === tag ||1136 -1 (decodedTag.tagStr + 'of') === tag || any;1137 862 }; 1138 8631139 -1 DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {1140 -1 const decodedTag = derDecodeTag(buffer,1141 -1 'Failed to decode tag of "' + tag + '"');1142 -1 if (buffer.isError(decodedTag))1143 -1 return decodedTag;1144 -11145 -1 let len = derDecodeLen(buffer,1146 -1 decodedTag.primitive,1147 -1 'Failed to get length of "' + tag + '"');1148 -11149 -1 // Failure1150 -1 if (buffer.isError(len))1151 -1 return len;1152 -11153 -1 if (!any &&1154 -1 decodedTag.tag !== tag &&1155 -1 decodedTag.tagStr !== tag &&1156 -1 decodedTag.tagStr + 'of' !== tag) {1157 -1 return buffer.error('Failed to match tag: "' + tag + '"');1158 -1 }1159 -11160 -1 if (decodedTag.primitive || len !== null)1161 -1 return buffer.skip(len, 'Failed to match body of: "' + tag + '"');1162 -11163 -1 // Indefinite length... find END tag1164 -1 const state = buffer.save();1165 -1 const res = this._skipUntilEnd(1166 -1 buffer,1167 -1 'Failed to skip indefinite length body: "' + this.tag + '"');1168 -1 if (buffer.isError(res))1169 -1 return res;1170 -11171 -1 len = buffer.offset - state.offset;1172 -1 buffer.restore(state);1173 -1 return buffer.skip(len, 'Failed to match body of: "' + tag + '"');1174 -1 };-1 864 /** -1 865 * @param {Element} element An element to check. -1 866 * @return {boolean} True if the element or one of its ancestors is -1 867 * hidden from accessibility. -1 868 */ -1 869 axs.utils.isElementOrAncestorHidden = function(element) { -1 870 if (axs.utils.isElementHidden(element)) -1 871 return true; 1175 8721176 -1 DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {1177 -1 for (;;) {1178 -1 const tag = derDecodeTag(buffer, fail);1179 -1 if (buffer.isError(tag))1180 -1 return tag;1181 -1 const len = derDecodeLen(buffer, tag.primitive, fail);1182 -1 if (buffer.isError(len))1183 -1 return len;1184 -11185 -1 let res;1186 -1 if (tag.primitive || len !== null)1187 -1 res = buffer.skip(len);-1 873 if (axs.dom.parentElement(element)) -1 874 return axs.utils.isElementOrAncestorHidden(axs.dom.parentElement(element)); 1188 875 else1189 -1 res = this._skipUntilEnd(buffer, fail);1190 -11191 -1 // Failure1192 -1 if (buffer.isError(res))1193 -1 return res;1194 -11195 -1 if (tag.tagStr === 'end')1196 -1 break;1197 -1 }1198 -1 };1199 -11200 -1 DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,1201 -1 options) {1202 -1 const result = [];1203 -1 while (!buffer.isEmpty()) {1204 -1 const possibleEnd = this._peekTag(buffer, 'end');1205 -1 if (buffer.isError(possibleEnd))1206 -1 return possibleEnd;1207 -11208 -1 const res = decoder.decode(buffer, 'der', options);1209 -1 if (buffer.isError(res) && possibleEnd)1210 -1 break;1211 -1 result.push(res);1212 -1 }1213 -1 return result;-1 876 return false; 1214 877 }; 1215 8781216 -1 DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {1217 -1 if (tag === 'bitstr') {1218 -1 const unused = buffer.readUInt8();1219 -1 if (buffer.isError(unused))1220 -1 return unused;1221 -1 return { unused: unused, data: buffer.raw() };1222 -1 } else if (tag === 'bmpstr') {1223 -1 const raw = buffer.raw();1224 -1 if (raw.length % 2 === 1)1225 -1 return buffer.error('Decoding of string type: bmpstr length mismatch');1226 -11227 -1 let str = '';1228 -1 for (let i = 0; i < raw.length / 2; i++) {1229 -1 str += String.fromCharCode(raw.readUInt16BE(i * 2));1230 -1 }1231 -1 return str;1232 -1 } else if (tag === 'numstr') {1233 -1 const numstr = buffer.raw().toString('ascii');1234 -1 if (!this._isNumstr(numstr)) {1235 -1 return buffer.error('Decoding of string type: ' +1236 -1 'numstr unsupported characters');1237 -1 }1238 -1 return numstr;1239 -1 } else if (tag === 'octstr') {1240 -1 return buffer.raw();1241 -1 } else if (tag === 'objDesc') {1242 -1 return buffer.raw();1243 -1 } else if (tag === 'printstr') {1244 -1 const printstr = buffer.raw().toString('ascii');1245 -1 if (!this._isPrintstr(printstr)) {1246 -1 return buffer.error('Decoding of string type: ' +1247 -1 'printstr unsupported characters');1248 -1 }1249 -1 return printstr;1250 -1 } else if (/str$/.test(tag)) {1251 -1 return buffer.raw().toString();1252 -1 } else {1253 -1 return buffer.error('Decoding of string type: ' + tag + ' unsupported');1254 -1 }-1 879 /** -1 880 * @param {Element} element An element to check -1 881 * @return {boolean} True if the given element is an inline element, false -1 882 * otherwise. -1 883 */ -1 884 axs.utils.isInlineElement = function(element) { -1 885 var tagName = element.tagName.toUpperCase(); -1 886 return axs.constants.InlineElements[tagName]; 1255 887 }; 1256 8881257 -1 DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {1258 -1 let result;1259 -1 const identifiers = [];1260 -1 let ident = 0;1261 -1 let subident = 0;1262 -1 while (!buffer.isEmpty()) {1263 -1 subident = buffer.readUInt8();1264 -1 ident <<= 7;1265 -1 ident |= subident & 0x7f;1266 -1 if ((subident & 0x80) === 0) {1267 -1 identifiers.push(ident);1268 -1 ident = 0;-1 889 /** -1 890 * -1 891 * Gets role details from an element. -1 892 * @param {Element} element The DOM element whose role we want. -1 893 * @param {boolean=} implicit if true then implicit semantics will be considered if there is no role attribute. -1 894 * -1 895 * @return {Object} -1 896 */ -1 897 axs.utils.getRoles = function(element, implicit) { -1 898 if (!element || element.nodeType !== Node.ELEMENT_NODE || (!element.hasAttribute('role') && !implicit)) -1 899 return null; -1 900 var roleValue = element.getAttribute('role'); -1 901 if (!roleValue && implicit) -1 902 roleValue = axs.properties.getImplicitRole(element); -1 903 if (!roleValue) // role='' or implicit role came up empty -1 904 return null; -1 905 var roleNames = roleValue.split(' '); -1 906 var result = { roles: [], valid: false }; -1 907 for (var i = 0; i < roleNames.length; i++) { -1 908 var role = roleNames[i]; -1 909 var ariaRole = axs.constants.ARIA_ROLES[role]; -1 910 var roleObject = { 'name': role }; -1 911 if (ariaRole && !ariaRole.abstract) { -1 912 roleObject.details = ariaRole; -1 913 if (!result.applied) { -1 914 result.applied = roleObject; -1 915 } -1 916 roleObject.valid = result.valid = true; -1 917 } else { -1 918 roleObject.valid = false; -1 919 } -1 920 result.roles.push(roleObject); 1269 921 }1270 -1 }1271 -1 if (subident & 0x80)1272 -1 identifiers.push(ident);1273 -11274 -1 const first = (identifiers[0] / 40) | 0;1275 -1 const second = identifiers[0] % 40;1276 -11277 -1 if (relative)1278 -1 result = identifiers;1279 -1 else1280 -1 result = [first, second].concat(identifiers.slice(1));1281 -11282 -1 if (values) {1283 -1 let tmp = values[result.join(' ')];1284 -1 if (tmp === undefined)1285 -1 tmp = values[result.join('.')];1286 -1 if (tmp !== undefined)1287 -1 result = tmp;1288 -1 }1289 -11290 -1 return result;1291 -1 };1292 -11293 -1 DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {1294 -1 const str = buffer.raw().toString();1295 -11296 -1 let year;1297 -1 let mon;1298 -1 let day;1299 -1 let hour;1300 -1 let min;1301 -1 let sec;1302 -1 if (tag === 'gentime') {1303 -1 year = str.slice(0, 4) | 0;1304 -1 mon = str.slice(4, 6) | 0;1305 -1 day = str.slice(6, 8) | 0;1306 -1 hour = str.slice(8, 10) | 0;1307 -1 min = str.slice(10, 12) | 0;1308 -1 sec = str.slice(12, 14) | 0;1309 -1 } else if (tag === 'utctime') {1310 -1 year = str.slice(0, 2) | 0;1311 -1 mon = str.slice(2, 4) | 0;1312 -1 day = str.slice(4, 6) | 0;1313 -1 hour = str.slice(6, 8) | 0;1314 -1 min = str.slice(8, 10) | 0;1315 -1 sec = str.slice(10, 12) | 0;1316 -1 if (year < 70)1317 -1 year = 2000 + year;1318 -1 else1319 -1 year = 1900 + year;1320 -1 } else {1321 -1 return buffer.error('Decoding ' + tag + ' time is not supported yet');1322 -1 }1323 -11324 -1 return Date.UTC(year, mon - 1, day, hour, min, sec, 0);1325 -1 };1326 -11327 -1 DERNode.prototype._decodeNull = function decodeNull() {1328 -1 return null;1329 -1 };1330 -11331 -1 DERNode.prototype._decodeBool = function decodeBool(buffer) {1332 -1 const res = buffer.readUInt8();1333 -1 if (buffer.isError(res))1334 -1 return res;1335 -1 else1336 -1 return res !== 0;1337 -1 };1338 -11339 -1 DERNode.prototype._decodeInt = function decodeInt(buffer, values) {1340 -1 // Bigint, return as it is (assume big endian)1341 -1 const raw = buffer.raw();1342 -1 let res = new bignum(raw);1343 9221344 -1 if (values)1345 -1 res = values[res.toString(10)] || res;1346 -11347 -1 return res;1348 -1 };1349 -11350 -1 DERNode.prototype._use = function use(entity, obj) {1351 -1 if (typeof entity === 'function')1352 -1 entity = entity(obj);1353 -1 return entity._getDecoder('der').tree;-1 923 return result; 1354 924 }; 1355 9251356 -1 // Utility methods1357 -11358 -1 function derDecodeTag(buf, fail) {1359 -1 let tag = buf.readUInt8(fail);1360 -1 if (buf.isError(tag))1361 -1 return tag;1362 -11363 -1 const cls = der.tagClass[tag >> 6];1364 -1 const primitive = (tag & 0x20) === 0;1365 -11366 -1 // Multi-octet tag - load1367 -1 if ((tag & 0x1f) === 0x1f) {1368 -1 let oct = tag;1369 -1 tag = 0;1370 -1 while ((oct & 0x80) === 0x80) {1371 -1 oct = buf.readUInt8(fail);1372 -1 if (buf.isError(oct))1373 -1 return oct;1374 -11375 -1 tag <<= 7;1376 -1 tag |= oct & 0x7f;-1 926 /** -1 927 * @param {!string} propertyName -1 928 * @param {!string} value -1 929 * @param {!Element} element -1 930 * @return {!Object} -1 931 */ -1 932 axs.utils.getAriaPropertyValue = function(propertyName, value, element) { -1 933 var propertyKey = propertyName.replace(/^aria-/, ''); -1 934 var property = axs.constants.ARIA_PROPERTIES[propertyKey]; -1 935 var result = { 'name': propertyName, 'rawValue': value }; -1 936 if (!property) { -1 937 result.valid = false; -1 938 result.reason = '"' + propertyName + '" is not a valid ARIA property'; -1 939 return result; 1377 940 }1378 -1 } else {1379 -1 tag &= 0x1f;1380 -1 }1381 -1 const tagStr = der.tag[tag];1382 -11383 -1 return {1384 -1 cls: cls,1385 -1 primitive: primitive,1386 -1 tag: tag,1387 -1 tagStr: tagStr1388 -1 };1389 -1 }1390 -11391 -1 function derDecodeLen(buf, primitive, fail) {1392 -1 let len = buf.readUInt8(fail);1393 -1 if (buf.isError(len))1394 -1 return len;1395 -11396 -1 // Indefinite form1397 -1 if (!primitive && len === 0x80)1398 -1 return null;1399 -11400 -1 // Definite form1401 -1 if ((len & 0x80) === 0) {1402 -1 // Short form1403 -1 return len;1404 -1 }1405 -11406 -1 // Long form1407 -1 const num = len & 0x7f;1408 -1 if (num > 4)1409 -1 return buf.error('length octect is too long');1410 -11411 -1 len = 0;1412 -1 for (let i = 0; i < num; i++) {1413 -1 len <<= 8;1414 -1 const j = buf.readUInt8(fail);1415 -1 if (buf.isError(j))1416 -1 return j;1417 -1 len |= j;1418 -1 }1419 -11420 -1 return len;1421 -1 }1422 -11423 -1 },{"../base/buffer":3,"../base/node":5,"../constants/der":7,"bn.js":15,"inherits":132}],10:[function(require,module,exports){1424 -1 'use strict';1425 9411426 -1 const decoders = exports;1427 -11428 -1 decoders.der = require('./der');1429 -1 decoders.pem = require('./pem');1430 -11431 -1 },{"./der":9,"./pem":11}],11:[function(require,module,exports){1432 -1 'use strict';-1 942 var propertyType = property.valueType; -1 943 if (!propertyType) { -1 944 result.valid = false; -1 945 result.reason = '"' + propertyName + '" is not a valid ARIA property'; -1 946 return result; -1 947 } 1433 9481434 -1 const inherits = require('inherits');1435 -1 const Buffer = require('safer-buffer').Buffer;1436 -11437 -1 const DERDecoder = require('./der');1438 -11439 -1 function PEMDecoder(entity) {1440 -1 DERDecoder.call(this, entity);1441 -1 this.enc = 'pem';1442 -1 }1443 -1 inherits(PEMDecoder, DERDecoder);1444 -1 module.exports = PEMDecoder;1445 -11446 -1 PEMDecoder.prototype.decode = function decode(data, options) {1447 -1 const lines = data.toString().split(/[\r\n]+/g);1448 -11449 -1 const label = options.label.toUpperCase();1450 -11451 -1 const re = /^-----(BEGIN|END) ([^-]+)-----$/;1452 -1 let start = -1;1453 -1 let end = -1;1454 -1 for (let i = 0; i < lines.length; i++) {1455 -1 const match = lines[i].match(re);1456 -1 if (match === null)1457 -1 continue;1458 -11459 -1 if (match[2] !== label)1460 -1 continue;1461 -11462 -1 if (start === -1) {1463 -1 if (match[1] !== 'BEGIN')1464 -1 break;1465 -1 start = i;1466 -1 } else {1467 -1 if (match[1] !== 'END')1468 -1 break;1469 -1 end = i;1470 -1 break;-1 949 switch (propertyType) { -1 950 case "idref": -1 951 var isValid = axs.utils.isValidIDRefValue(value, element); -1 952 result.valid = isValid.valid; -1 953 result.reason = isValid.reason; -1 954 result.idref = isValid.idref; -1 955 // falls through -1 956 case "idref_list": -1 957 var idrefValues = value.split(/\s+/); -1 958 result.valid = true; -1 959 for (var i = 0; i < idrefValues.length; i++) { -1 960 var refIsValid = axs.utils.isValidIDRefValue(idrefValues[i], element); -1 961 if (!refIsValid.valid) -1 962 result.valid = false; -1 963 if (result.values) -1 964 result.values.push(refIsValid); -1 965 else -1 966 result.values = [refIsValid]; -1 967 } -1 968 return result; -1 969 case "integer": -1 970 var validNumber = axs.utils.isValidNumber(value); -1 971 if (!validNumber.valid) { -1 972 result.valid = false; -1 973 result.reason = validNumber.reason; -1 974 return result; -1 975 } -1 976 if (Math.floor(validNumber.value) !== validNumber.value) { -1 977 result.valid = false; -1 978 result.reason = '' + value + ' is not a whole integer'; -1 979 } else { -1 980 result.valid = true; -1 981 result.value = validNumber.value; -1 982 } -1 983 return result; -1 984 case "decimal": -1 985 case "number": -1 986 var validNumber = axs.utils.isValidNumber(value); -1 987 result.valid = validNumber.valid; -1 988 if (!validNumber.valid) { -1 989 result.reason = validNumber.reason; -1 990 return result; -1 991 } -1 992 result.value = validNumber.value; -1 993 return result; -1 994 case "string": -1 995 result.valid = true; -1 996 result.value = value; -1 997 return result; -1 998 case "token": -1 999 var validTokenValue = axs.utils.isValidTokenValue(propertyName, value.toLowerCase()); -1 1000 if (validTokenValue.valid) { -1 1001 result.valid = true; -1 1002 result.value = validTokenValue.value; -1 1003 return result; -1 1004 } else { -1 1005 result.valid = false; -1 1006 result.value = value; -1 1007 result.reason = validTokenValue.reason; -1 1008 return result; -1 1009 } -1 1010 // falls through -1 1011 case "token_list": -1 1012 var tokenValues = value.split(/\s+/); -1 1013 result.valid = true; -1 1014 for (var i = 0; i < tokenValues.length; i++) { -1 1015 var validTokenValue = axs.utils.isValidTokenValue(propertyName, tokenValues[i].toLowerCase()); -1 1016 if (!validTokenValue.valid) { -1 1017 result.valid = false; -1 1018 if (result.reason) { -1 1019 result.reason = [ result.reason ]; -1 1020 result.reason.push(validTokenValue.reason); -1 1021 } else { -1 1022 result.reason = validTokenValue.reason; -1 1023 result.possibleValues = validTokenValue.possibleValues; -1 1024 } -1 1025 } -1 1026 // TODO (more structured result) -1 1027 if (result.values) -1 1028 result.values.push(validTokenValue.value); -1 1029 else -1 1030 result.values = [validTokenValue.value]; -1 1031 } -1 1032 return result; -1 1033 case "tristate": -1 1034 var validTristate = axs.utils.isPossibleValue(value.toLowerCase(), axs.constants.MIXED_VALUES, propertyName); -1 1035 if (validTristate.valid) { -1 1036 result.valid = true; -1 1037 result.value = validTristate.value; -1 1038 } else { -1 1039 result.valid = false; -1 1040 result.value = value; -1 1041 result.reason = validTristate.reason; -1 1042 } -1 1043 return result; -1 1044 case "boolean": -1 1045 var validBoolean = axs.utils.isValidBoolean(value); -1 1046 if (validBoolean.valid) { -1 1047 result.valid = true; -1 1048 result.value = validBoolean.value; -1 1049 } else { -1 1050 result.valid = false; -1 1051 result.value = value; -1 1052 result.reason = validBoolean.reason; -1 1053 } -1 1054 return result; 1471 1055 }1472 -1 }1473 -1 if (start === -1 || end === -1)1474 -1 throw new Error('PEM section not found for: ' + label);1475 -11476 -1 const base64 = lines.slice(start + 1, end).join('');1477 -1 // Remove excessive symbols1478 -1 base64.replace(/[^a-z0-9+/=]+/gi, '');1479 -11480 -1 const input = Buffer.from(base64, 'base64');1481 -1 return DERDecoder.prototype.decode.call(this, input, options);1482 -1 };1483 -11484 -1 },{"./der":9,"inherits":132,"safer-buffer":161}],12:[function(require,module,exports){1485 -1 'use strict';1486 -11487 -1 const inherits = require('inherits');1488 -1 const Buffer = require('safer-buffer').Buffer;1489 -1 const Node = require('../base/node');1490 -11491 -1 // Import DER constants1492 -1 const der = require('../constants/der');1493 -11494 -1 function DEREncoder(entity) {1495 -1 this.enc = 'der';1496 -1 this.name = entity.name;1497 -1 this.entity = entity;1498 -11499 -1 // Construct base tree1500 -1 this.tree = new DERNode();1501 -1 this.tree._init(entity.body);1502 -1 }1503 -1 module.exports = DEREncoder;1504 -11505 -1 DEREncoder.prototype.encode = function encode(data, reporter) {1506 -1 return this.tree._encode(data, reporter).join();1507 -1 };1508 -11509 -1 // Tree methods1510 -11511 -1 function DERNode(parent) {1512 -1 Node.call(this, 'der', parent);1513 -1 }1514 -1 inherits(DERNode, Node);1515 -11516 -1 DERNode.prototype._encodeComposite = function encodeComposite(tag,1517 -1 primitive,1518 -1 cls,1519 -1 content) {1520 -1 const encodedTag = encodeTag(tag, primitive, cls, this.reporter);1521 -11522 -1 // Short form1523 -1 if (content.length < 0x80) {1524 -1 const header = Buffer.alloc(2);1525 -1 header[0] = encodedTag;1526 -1 header[1] = content.length;1527 -1 return this._createEncoderBuffer([ header, content ]);1528 -1 }1529 -11530 -1 // Long form1531 -1 // Count octets required to store length1532 -1 let lenOctets = 1;1533 -1 for (let i = content.length; i >= 0x100; i >>= 8)1534 -1 lenOctets++;1535 -11536 -1 const header = Buffer.alloc(1 + 1 + lenOctets);1537 -1 header[0] = encodedTag;1538 -1 header[1] = 0x80 | lenOctets;1539 -11540 -1 for (let i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)1541 -1 header[i] = j & 0xff;1542 -11543 -1 return this._createEncoderBuffer([ header, content ]);-1 1056 result.valid = false; -1 1057 result.reason = 'Not a valid ARIA property'; -1 1058 return result; 1544 1059 }; 1545 10601546 -1 DERNode.prototype._encodeStr = function encodeStr(str, tag) {1547 -1 if (tag === 'bitstr') {1548 -1 return this._createEncoderBuffer([ str.unused | 0, str.data ]);1549 -1 } else if (tag === 'bmpstr') {1550 -1 const buf = Buffer.alloc(str.length * 2);1551 -1 for (let i = 0; i < str.length; i++) {1552 -1 buf.writeUInt16BE(str.charCodeAt(i), i * 2);1553 -1 }1554 -1 return this._createEncoderBuffer(buf);1555 -1 } else if (tag === 'numstr') {1556 -1 if (!this._isNumstr(str)) {1557 -1 return this.reporter.error('Encoding of string type: numstr supports ' +1558 -1 'only digits and space');1559 -1 }1560 -1 return this._createEncoderBuffer(str);1561 -1 } else if (tag === 'printstr') {1562 -1 if (!this._isPrintstr(str)) {1563 -1 return this.reporter.error('Encoding of string type: printstr supports ' +1564 -1 'only latin upper and lower case letters, ' +1565 -1 'digits, space, apostrophe, left and rigth ' +1566 -1 'parenthesis, plus sign, comma, hyphen, ' +1567 -1 'dot, slash, colon, equal sign, ' +1568 -1 'question mark');1569 -1 }1570 -1 return this._createEncoderBuffer(str);1571 -1 } else if (/str$/.test(tag)) {1572 -1 return this._createEncoderBuffer(str);1573 -1 } else if (tag === 'objDesc') {1574 -1 return this._createEncoderBuffer(str);1575 -1 } else {1576 -1 return this.reporter.error('Encoding of string type: ' + tag +1577 -1 ' unsupported');1578 -1 }-1 1061 /** -1 1062 * @param {string} propertyName The name of the property. -1 1063 * @param {string} value The value to check. -1 1064 * @return {!Object} -1 1065 */ -1 1066 axs.utils.isValidTokenValue = function(propertyName, value) { -1 1067 var propertyKey = propertyName.replace(/^aria-/, ''); -1 1068 var propertyDetails = axs.constants.ARIA_PROPERTIES[propertyKey]; -1 1069 var possibleValues = propertyDetails.valuesSet; -1 1070 return axs.utils.isPossibleValue(value, possibleValues, propertyName); 1579 1071 }; 1580 10721581 -1 DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {1582 -1 if (typeof id === 'string') {1583 -1 if (!values)1584 -1 return this.reporter.error('string objid given, but no values map found');1585 -1 if (!values.hasOwnProperty(id))1586 -1 return this.reporter.error('objid not found in values map');1587 -1 id = values[id].split(/[\s.]+/g);1588 -1 for (let i = 0; i < id.length; i++)1589 -1 id[i] |= 0;1590 -1 } else if (Array.isArray(id)) {1591 -1 id = id.slice();1592 -1 for (let i = 0; i < id.length; i++)1593 -1 id[i] |= 0;1594 -1 }1595 -11596 -1 if (!Array.isArray(id)) {1597 -1 return this.reporter.error('objid() should be either array or string, ' +1598 -1 'got: ' + JSON.stringify(id));1599 -1 }1600 -11601 -1 if (!relative) {1602 -1 if (id[1] >= 40)1603 -1 return this.reporter.error('Second objid identifier OOB');1604 -1 id.splice(0, 2, id[0] * 40 + id[1]);1605 -1 }1606 -11607 -1 // Count number of octets1608 -1 let size = 0;1609 -1 for (let i = 0; i < id.length; i++) {1610 -1 let ident = id[i];1611 -1 for (size++; ident >= 0x80; ident >>= 7)1612 -1 size++;1613 -1 }1614 -11615 -1 const objid = Buffer.alloc(size);1616 -1 let offset = objid.length - 1;1617 -1 for (let i = id.length - 1; i >= 0; i--) {1618 -1 let ident = id[i];1619 -1 objid[offset--] = ident & 0x7f;1620 -1 while ((ident >>= 7) > 0)1621 -1 objid[offset--] = 0x80 | (ident & 0x7f);1622 -1 }1623 -11624 -1 return this._createEncoderBuffer(objid);-1 1073 /** -1 1074 * @param {string} value -1 1075 * @param {Object.<string, boolean>} possibleValues -1 1076 * @param {string} propertyName The name of the property. -1 1077 * @return {!Object} -1 1078 */ -1 1079 axs.utils.isPossibleValue = function(value, possibleValues, propertyName) { -1 1080 if (!possibleValues[value]) -1 1081 return { 'valid': false, -1 1082 'value': value, -1 1083 'reason': '"' + value + '" is not a valid value for ' + propertyName, -1 1084 'possibleValues': Object.keys(possibleValues) }; -1 1085 return { 'valid': true, 'value': value }; 1625 1086 }; 1626 10871627 -1 function two(num) {1628 -1 if (num < 10)1629 -1 return '0' + num;1630 -1 else1631 -1 return num;1632 -1 }1633 -11634 -1 DERNode.prototype._encodeTime = function encodeTime(time, tag) {1635 -1 let str;1636 -1 const date = new Date(time);1637 -11638 -1 if (tag === 'gentime') {1639 -1 str = [1640 -1 two(date.getUTCFullYear()),1641 -1 two(date.getUTCMonth() + 1),1642 -1 two(date.getUTCDate()),1643 -1 two(date.getUTCHours()),1644 -1 two(date.getUTCMinutes()),1645 -1 two(date.getUTCSeconds()),1646 -1 'Z'1647 -1 ].join('');1648 -1 } else if (tag === 'utctime') {1649 -1 str = [1650 -1 two(date.getUTCFullYear() % 100),1651 -1 two(date.getUTCMonth() + 1),1652 -1 two(date.getUTCDate()),1653 -1 two(date.getUTCHours()),1654 -1 two(date.getUTCMinutes()),1655 -1 two(date.getUTCSeconds()),1656 -1 'Z'1657 -1 ].join('');1658 -1 } else {1659 -1 this.reporter.error('Encoding ' + tag + ' time is not supported yet');1660 -1 }1661 -11662 -1 return this._encodeStr(str, 'octstr');-1 1088 /** -1 1089 * @param {string} value -1 1090 * @return {!Object} -1 1091 */ -1 1092 axs.utils.isValidBoolean = function(value) { -1 1093 try { -1 1094 var parsedValue = JSON.parse(value); -1 1095 } catch (e) { -1 1096 parsedValue = ''; -1 1097 } -1 1098 if (typeof(parsedValue) != 'boolean') -1 1099 return { 'valid': false, -1 1100 'value': value, -1 1101 'reason': '"' + value + '" is not a true/false value' }; -1 1102 return { 'valid': true, 'value': parsedValue }; 1663 1103 }; 1664 11041665 -1 DERNode.prototype._encodeNull = function encodeNull() {1666 -1 return this._createEncoderBuffer('');-1 1105 /** -1 1106 * @param {string} value -1 1107 * @param {!Element} element -1 1108 * @return {!Object} -1 1109 */ -1 1110 axs.utils.isValidIDRefValue = function(value, element) { -1 1111 if (value.length == 0) -1 1112 return { 'valid': true, 'idref': value }; -1 1113 if (!element.ownerDocument.getElementById(value)) -1 1114 return { 'valid': false, -1 1115 'idref': value, -1 1116 'reason': 'No element with ID "' + value + '"' }; -1 1117 return { 'valid': true, 'idref': value }; 1667 1118 }; 1668 11191669 -1 DERNode.prototype._encodeInt = function encodeInt(num, values) {1670 -1 if (typeof num === 'string') {1671 -1 if (!values)1672 -1 return this.reporter.error('String int or enum given, but no values map');1673 -1 if (!values.hasOwnProperty(num)) {1674 -1 return this.reporter.error('Values map doesn\'t contain: ' +1675 -1 JSON.stringify(num));-1 1120 /** -1 1121 * Tests if a number is real number for a11y purposes. -1 1122 * Must be a real, numerical, decimal value; heavily inspired by -1 1123 * http://www.w3.org/TR/wai-aria/states_and_properties#valuetype_number -1 1124 * @param {string} value -1 1125 * @return {!Object} -1 1126 */ -1 1127 axs.utils.isValidNumber = function(value) { -1 1128 var failResult = { -1 1129 'valid': false, -1 1130 'value': value, -1 1131 'reason': '"' + value + '" is not a number' -1 1132 }; -1 1133 if (!value) { -1 1134 return failResult; 1676 1135 }1677 -1 num = values[num];1678 -1 }1679 -11680 -1 // Bignum, assume big endian1681 -1 if (typeof num !== 'number' && !Buffer.isBuffer(num)) {1682 -1 const numArray = num.toArray();1683 -1 if (!num.sign && numArray[0] & 0x80) {1684 -1 numArray.unshift(0);-1 1136 if (/^0x/i.test(value)) { -1 1137 failResult.reason = '"' + value + '" is not a decimal number'; // hex is not accepted -1 1138 return failResult; 1685 1139 }1686 -1 num = Buffer.from(numArray);1687 -1 }1688 -11689 -1 if (Buffer.isBuffer(num)) {1690 -1 let size = num.length;1691 -1 if (num.length === 0)1692 -1 size++;1693 -11694 -1 const out = Buffer.alloc(size);1695 -1 num.copy(out);1696 -1 if (num.length === 0)1697 -1 out[0] = 0;1698 -1 return this._createEncoderBuffer(out);1699 -1 }1700 -11701 -1 if (num < 0x80)1702 -1 return this._createEncoderBuffer(num);1703 -11704 -1 if (num < 0x100)1705 -1 return this._createEncoderBuffer([0, num]);1706 -11707 -1 let size = 1;1708 -1 for (let i = num; i >= 0x100; i >>= 8)1709 -1 size++;1710 -11711 -1 const out = new Array(size);1712 -1 for (let i = out.length - 1; i >= 0; i--) {1713 -1 out[i] = num & 0xff;1714 -1 num >>= 8;1715 -1 }1716 -1 if(out[0] & 0x80) {1717 -1 out.unshift(0);1718 -1 }1719 -11720 -1 return this._createEncoderBuffer(Buffer.from(out));1721 -1 };1722 -11723 -1 DERNode.prototype._encodeBool = function encodeBool(value) {1724 -1 return this._createEncoderBuffer(value ? 0xff : 0);1725 -1 };1726 -11727 -1 DERNode.prototype._use = function use(entity, obj) {1728 -1 if (typeof entity === 'function')1729 -1 entity = entity(obj);1730 -1 return entity._getEncoder('der').tree;-1 1140 var parsedValue = value * 1; -1 1141 if (!isFinite(parsedValue)) { -1 1142 return failResult; -1 1143 } -1 1144 return { 'valid': true, 'value': parsedValue }; 1731 1145 }; 1732 11461733 -1 DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {1734 -1 const state = this._baseState;1735 -1 let i;1736 -1 if (state['default'] === null)1737 -1 return false;1738 -11739 -1 const data = dataBuffer.join();1740 -1 if (state.defaultBuffer === undefined)1741 -1 state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();-1 1147 /** -1 1148 * @param {Element} element -1 1149 * @return {boolean} -1 1150 */ -1 1151 axs.utils.isElementImplicitlyFocusable = function(element) { -1 1152 var defaultView = element.ownerDocument.defaultView; 1742 11531743 -1 if (data.length !== state.defaultBuffer.length)-1 1154 if (element instanceof defaultView.HTMLAnchorElement || -1 1155 element instanceof defaultView.HTMLAreaElement) -1 1156 return element.hasAttribute('href'); -1 1157 if (element instanceof defaultView.HTMLInputElement || -1 1158 element instanceof defaultView.HTMLSelectElement || -1 1159 element instanceof defaultView.HTMLTextAreaElement || -1 1160 element instanceof defaultView.HTMLButtonElement || -1 1161 element instanceof defaultView.HTMLIFrameElement) -1 1162 return !element.disabled; 1744 1163 return false;1745 -11746 -1 for (i=0; i < data.length; i++)1747 -1 if (data[i] !== state.defaultBuffer[i])1748 -1 return false;1749 -11750 -1 return true;1751 -1 };1752 -11753 -1 // Utility methods1754 -11755 -1 function encodeTag(tag, primitive, cls, reporter) {1756 -1 let res;1757 -11758 -1 if (tag === 'seqof')1759 -1 tag = 'seq';1760 -1 else if (tag === 'setof')1761 -1 tag = 'set';1762 -11763 -1 if (der.tagByName.hasOwnProperty(tag))1764 -1 res = der.tagByName[tag];1765 -1 else if (typeof tag === 'number' && (tag | 0) === tag)1766 -1 res = tag;1767 -1 else1768 -1 return reporter.error('Unknown tag: ' + tag);1769 -11770 -1 if (res >= 0x1f)1771 -1 return reporter.error('Multi-octet tag encoding unsupported');1772 -11773 -1 if (!primitive)1774 -1 res |= 0x20;1775 -11776 -1 res |= (der.tagClassByName[cls || 'universal'] << 6);1777 -11778 -1 return res;1779 -1 }1780 -11781 -1 },{"../base/node":5,"../constants/der":7,"inherits":132,"safer-buffer":161}],13:[function(require,module,exports){1782 -1 'use strict';1783 -11784 -1 const encoders = exports;1785 -11786 -1 encoders.der = require('./der');1787 -1 encoders.pem = require('./pem');1788 -11789 -1 },{"./der":12,"./pem":14}],14:[function(require,module,exports){1790 -1 'use strict';1791 -11792 -1 const inherits = require('inherits');1793 -11794 -1 const DEREncoder = require('./der');1795 -11796 -1 function PEMEncoder(entity) {1797 -1 DEREncoder.call(this, entity);1798 -1 this.enc = 'pem';1799 -1 }1800 -1 inherits(PEMEncoder, DEREncoder);1801 -1 module.exports = PEMEncoder;1802 -11803 -1 PEMEncoder.prototype.encode = function encode(data, options) {1804 -1 const buf = DEREncoder.prototype.encode.call(this, data);1805 -11806 -1 const p = buf.toString('base64');1807 -1 const out = [ '-----BEGIN ' + options.label + '-----' ];1808 -1 for (let i = 0; i < p.length; i += 64)1809 -1 out.push(p.slice(i, i + 64));1810 -1 out.push('-----END ' + options.label + '-----');1811 -1 return out.join('\n');1812 1164 }; 1813 11651814 -1 },{"./der":12,"inherits":132}],15:[function(require,module,exports){1815 -1 (function (module, exports) {1816 -1 'use strict';1817 -11818 -1 // Utils1819 -1 function assert (val, msg) {1820 -1 if (!val) throw new Error(msg || 'Assertion failed');1821 -1 }1822 -11823 -1 // Could use `inherits` module, but don't want to move from single file1824 -1 // architecture yet.1825 -1 function inherits (ctor, superCtor) {1826 -1 ctor.super_ = superCtor;1827 -1 var TempCtor = function () {};1828 -1 TempCtor.prototype = superCtor.prototype;1829 -1 ctor.prototype = new TempCtor();1830 -1 ctor.prototype.constructor = ctor;1831 -1 }1832 -11833 -1 // BN1834 -11835 -1 function BN (number, base, endian) {1836 -1 if (BN.isBN(number)) {1837 -1 return number;-1 1166 /** -1 1167 * Returns an array containing the values of the given JSON-compatible object. -1 1168 * (Simply ignores any function values.) -1 1169 * @param {Object} obj -1 1170 * @return {Array} -1 1171 */ -1 1172 axs.utils.values = function(obj) { -1 1173 var values = []; -1 1174 for (var key in obj) { -1 1175 if (obj.hasOwnProperty(key) && typeof obj[key] != 'function') -1 1176 values.push(obj[key]); 1838 1177 } -1 1178 return values; -1 1179 }; 1839 11801840 -1 this.negative = 0;1841 -1 this.words = null;1842 -1 this.length = 0;1843 -11844 -1 // Reduction context1845 -1 this.red = null;1846 -11847 -1 if (number !== null) {1848 -1 if (base === 'le' || base === 'be') {1849 -1 endian = base;1850 -1 base = 10;1851 -1 }1852 -11853 -1 this._init(number || 0, base || 10, endian || 'be');-1 1181 /** -1 1182 * Returns an object containing the same keys and values as the given -1 1183 * JSON-compatible object. (Simply ignores any function values.) -1 1184 * @param {Object} obj -1 1185 * @return {Object} -1 1186 */ -1 1187 axs.utils.namedValues = function(obj) { -1 1188 var values = {}; -1 1189 for (var key in obj) { -1 1190 if (obj.hasOwnProperty(key) && typeof obj[key] != 'function') -1 1191 values[key] = obj[key]; 1854 1192 }1855 -1 }1856 -1 if (typeof module === 'object') {1857 -1 module.exports = BN;1858 -1 } else {1859 -1 exports.BN = BN;1860 -1 }-1 1193 return values; -1 1194 }; 1861 11951862 -1 BN.BN = BN;1863 -1 BN.wordSize = 26;-1 1196 /** -1 1197 * Escapes a given ID to be used in a CSS selector -1 1198 * -1 1199 * @private -1 1200 * @param {!string} id The ID to be escaped -1 1201 * @return {string} The escaped ID -1 1202 */ -1 1203 function escapeId(id) { -1 1204 return id.replace(/[^a-zA-Z0-9_-]/g,function(match) { return '\\' + match; }); -1 1205 } 1864 12061865 -1 var Buffer;1866 -1 try {1867 -1 if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {1868 -1 Buffer = window.Buffer;1869 -1 } else {1870 -1 Buffer = require('buffer').Buffer;1871 -1 }1872 -1 } catch (e) {-1 1207 /** Gets a CSS selector text for a DOM object. -1 1208 * @param {Node} obj The DOM object. -1 1209 * @return {string} CSS selector text for the DOM object. -1 1210 */ -1 1211 axs.utils.getQuerySelectorText = function(obj) { -1 1212 if (obj == null || obj.tagName == 'HTML') { -1 1213 return 'html'; -1 1214 } else if (obj.tagName == 'BODY') { -1 1215 return 'body'; 1873 1216 } 1874 12171875 -1 BN.isBN = function isBN (num) {1876 -1 if (num instanceof BN) {1877 -1 return true;1878 -1 }1879 -11880 -1 return num !== null && typeof num === 'object' &&1881 -1 num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);1882 -1 };1883 -11884 -1 BN.max = function max (left, right) {1885 -1 if (left.cmp(right) > 0) return left;1886 -1 return right;1887 -1 };1888 -11889 -1 BN.min = function min (left, right) {1890 -1 if (left.cmp(right) < 0) return left;1891 -1 return right;1892 -1 };1893 -11894 -1 BN.prototype._init = function init (number, base, endian) {1895 -1 if (typeof number === 'number') {1896 -1 return this._initNumber(number, base, endian);1897 -1 }1898 -11899 -1 if (typeof number === 'object') {1900 -1 return this._initArray(number, base, endian);1901 -1 }1902 -11903 -1 if (base === 'hex') {1904 -1 base = 16;-1 1218 if (obj.hasAttribute) { -1 1219 if (obj.id) { -1 1220 return '#' + escapeId(obj.id); 1905 1221 }1906 -1 assert(base === (base | 0) && base >= 2 && base <= 36);1907 12221908 -1 number = number.toString().replace(/\s+/g, '');1909 -1 var start = 0;1910 -1 if (number[0] === '-') {1911 -1 start++;1912 -1 this.negative = 1;1913 -1 }-1 1223 if (obj.className) { -1 1224 var selector = ''; -1 1225 for (var i = 0; i < obj.classList.length; i++) -1 1226 selector += '.' + obj.classList[i]; 1914 12271915 -1 if (start < number.length) {1916 -1 if (base === 16) {1917 -1 this._parseHex(number, start, endian);1918 -1 } else {1919 -1 this._parseBase(number, base, start);1920 -1 if (endian === 'le') {1921 -1 this._initArray(this.toArray(), base, endian);-1 1228 var total = 0; -1 1229 if (obj.parentNode) { -1 1230 for (i = 0; i < obj.parentNode.children.length; i++) { -1 1231 var similar = obj.parentNode.children[i]; -1 1232 if (axs.browserUtils.matchSelector(similar, selector)) -1 1233 total++; -1 1234 if (similar === obj) -1 1235 break; 1922 1236 } -1 1237 } else { -1 1238 total = 1; 1923 1239 }1924 -1 }1925 -1 };1926 -11927 -1 BN.prototype._initNumber = function _initNumber (number, base, endian) {1928 -1 if (number < 0) {1929 -1 this.negative = 1;1930 -1 number = -number;1931 -1 }1932 -1 if (number < 0x4000000) {1933 -1 this.words = [ number & 0x3ffffff ];1934 -1 this.length = 1;1935 -1 } else if (number < 0x10000000000000) {1936 -1 this.words = [1937 -1 number & 0x3ffffff,1938 -1 (number / 0x4000000) & 0x3ffffff1939 -1 ];1940 -1 this.length = 2;1941 -1 } else {1942 -1 assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)1943 -1 this.words = [1944 -1 number & 0x3ffffff,1945 -1 (number / 0x4000000) & 0x3ffffff,1946 -1 11947 -1 ];1948 -1 this.length = 3;1949 -1 }1950 12401951 -1 if (endian !== 'le') return;1952 -11953 -1 // Reverse the bytes1954 -1 this._initArray(this.toArray(), base, endian);1955 -1 };1956 -11957 -1 BN.prototype._initArray = function _initArray (number, base, endian) {1958 -1 // Perhaps a Uint8Array1959 -1 assert(typeof number.length === 'number');1960 -1 if (number.length <= 0) {1961 -1 this.words = [ 0 ];1962 -1 this.length = 1;1963 -1 return this;1964 -1 }1965 -11966 -1 this.length = Math.ceil(number.length / 3);1967 -1 this.words = new Array(this.length);1968 -1 for (var i = 0; i < this.length; i++) {1969 -1 this.words[i] = 0;1970 -1 }1971 -11972 -1 var j, w;1973 -1 var off = 0;1974 -1 if (endian === 'be') {1975 -1 for (i = number.length - 1, j = 0; i >= 0; i -= 3) {1976 -1 w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);1977 -1 this.words[j] |= (w << off) & 0x3ffffff;1978 -1 this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;1979 -1 off += 24;1980 -1 if (off >= 26) {1981 -1 off -= 26;1982 -1 j++;1983 -1 }1984 -1 }1985 -1 } else if (endian === 'le') {1986 -1 for (i = 0, j = 0; i < number.length; i += 3) {1987 -1 w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);1988 -1 this.words[j] |= (w << off) & 0x3ffffff;1989 -1 this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;1990 -1 off += 24;1991 -1 if (off >= 26) {1992 -1 off -= 26;1993 -1 j++;1994 -1 }-1 1241 if (total == 1) { -1 1242 return axs.utils.getQuerySelectorText(obj.parentNode) + -1 1243 ' > ' + selector; 1995 1244 } 1996 1245 }1997 -1 return this.strip();1998 -1 };1999 -12000 -1 function parseHex4Bits (string, index) {2001 -1 var c = string.charCodeAt(index);2002 -1 // 'A' - 'F'2003 -1 if (c >= 65 && c <= 70) {2004 -1 return c - 55;2005 -1 // 'a' - 'f'2006 -1 } else if (c >= 97 && c <= 102) {2007 -1 return c - 87;2008 -1 // '0' - '9'2009 -1 } else {2010 -1 return (c - 48) & 0xf;2011 -1 }2012 -1 }2013 -12014 -1 function parseHexByte (string, lowerBound, index) {2015 -1 var r = parseHex4Bits(string, index);2016 -1 if (index - 1 >= lowerBound) {2017 -1 r |= parseHex4Bits(string, index - 1) << 4;2018 -1 }2019 -1 return r;2020 -1 }2021 12462022 -1 BN.prototype._parseHex = function _parseHex (number, start, endian) {2023 -1 // Create possibly bigger array to ensure that it fits the number2024 -1 this.length = Math.ceil((number.length - start) / 6);2025 -1 this.words = new Array(this.length);2026 -1 for (var i = 0; i < this.length; i++) {2027 -1 this.words[i] = 0;2028 -1 }2029 -12030 -1 // 24-bits chunks2031 -1 var off = 0;2032 -1 var j = 0;2033 -12034 -1 var w;2035 -1 if (endian === 'be') {2036 -1 for (i = number.length - 1; i >= start; i -= 2) {2037 -1 w = parseHexByte(number, start, i) << off;2038 -1 this.words[j] |= w & 0x3ffffff;2039 -1 if (off >= 18) {2040 -1 off -= 18;2041 -1 j += 1;2042 -1 this.words[j] |= w >>> 26;2043 -1 } else {2044 -1 off += 8;2045 -1 }2046 -1 }2047 -1 } else {2048 -1 var parseLength = number.length - start;2049 -1 for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {2050 -1 w = parseHexByte(number, start, i) << off;2051 -1 this.words[j] |= w & 0x3ffffff;2052 -1 if (off >= 18) {2053 -1 off -= 18;2054 -1 j += 1;2055 -1 this.words[j] |= w >>> 26;2056 -1 } else {2057 -1 off += 8;-1 1247 if (obj.parentNode) { -1 1248 var similarTags = obj.parentNode.children; -1 1249 var total = 1; -1 1250 var i = 0; -1 1251 while (similarTags[i] !== obj) { -1 1252 if (similarTags[i].tagName == obj.tagName) { -1 1253 total++; 2058 1254 } -1 1255 i++; 2059 1256 }2060 -1 }2061 -12062 -1 this.strip();2063 -1 };2064 -12065 -1 function parseBase (str, start, end, mul) {2066 -1 var r = 0;2067 -1 var len = Math.min(str.length, end);2068 -1 for (var i = start; i < len; i++) {2069 -1 var c = str.charCodeAt(i) - 48;2070 -12071 -1 r *= mul;2072 -12073 -1 // 'a'2074 -1 if (c >= 49) {2075 -1 r += c - 49 + 0xa;2076 -12077 -1 // 'A'2078 -1 } else if (c >= 17) {2079 -1 r += c - 17 + 0xa;2080 -12081 -1 // '0' - '9'2082 -1 } else {2083 -1 r += c;2084 -1 }2085 -1 }2086 -1 return r;2087 -1 }2088 -12089 -1 BN.prototype._parseBase = function _parseBase (number, base, start) {2090 -1 // Initialize as zero2091 -1 this.words = [ 0 ];2092 -1 this.length = 1;2093 -12094 -1 // Find length of limb in base2095 -1 for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {2096 -1 limbLen++;2097 -1 }2098 -1 limbLen--;2099 -1 limbPow = (limbPow / base) | 0;2100 -12101 -1 var total = number.length - start;2102 -1 var mod = total % limbLen;2103 -1 var end = Math.min(total, total - mod) + start;2104 -12105 -1 var word = 0;2106 -1 for (var i = start; i < end; i += limbLen) {2107 -1 word = parseBase(number, i, i + limbLen, base);2108 -12109 -1 this.imuln(limbPow);2110 -1 if (this.words[0] + word < 0x4000000) {2111 -1 this.words[0] += word;2112 -1 } else {2113 -1 this._iaddn(word);2114 -1 }2115 -1 }2116 12572117 -1 if (mod !== 0) {2118 -1 var pow = 1;2119 -1 word = parseBase(number, i, number.length, base);2120 -12121 -1 for (i = 0; i < mod; i++) {2122 -1 pow *= base;-1 1258 var next = ''; -1 1259 if (obj.parentNode.tagName != 'BODY') { -1 1260 next = axs.utils.getQuerySelectorText(obj.parentNode) + -1 1261 ' > '; 2123 1262 } 2124 12632125 -1 this.imuln(pow);2126 -1 if (this.words[0] + word < 0x4000000) {2127 -1 this.words[0] += word;-1 1264 if (total == 1) { -1 1265 return next + -1 1266 obj.tagName; 2128 1267 } else {2129 -1 this._iaddn(word);-1 1268 return next + -1 1269 obj.tagName + -1 1270 ':nth-of-type(' + total + ')'; 2130 1271 } 2131 1272 } 2132 12732133 -1 this.strip();2134 -1 };2135 -12136 -1 BN.prototype.copy = function copy (dest) {2137 -1 dest.words = new Array(this.length);2138 -1 for (var i = 0; i < this.length; i++) {2139 -1 dest.words[i] = this.words[i];2140 -1 }2141 -1 dest.length = this.length;2142 -1 dest.negative = this.negative;2143 -1 dest.red = this.red;2144 -1 };2145 -12146 -1 BN.prototype.clone = function clone () {2147 -1 var r = new BN(null);2148 -1 this.copy(r);2149 -1 return r;2150 -1 };2151 -12152 -1 BN.prototype._expand = function _expand (size) {2153 -1 while (this.length < size) {2154 -1 this.words[this.length++] = 0;2155 -1 }2156 -1 return this;2157 -1 };2158 -12159 -1 // Remove leading `0` from `this`2160 -1 BN.prototype.strip = function strip () {2161 -1 while (this.length > 1 && this.words[this.length - 1] === 0) {2162 -1 this.length--;2163 -1 }2164 -1 return this._normSign();2165 -1 };2166 -12167 -1 BN.prototype._normSign = function _normSign () {2168 -1 // -0 = 02169 -1 if (this.length === 1 && this.words[0] === 0) {2170 -1 this.negative = 0;2171 -1 }2172 -1 return this;2173 -1 };2174 -12175 -1 BN.prototype.inspect = function inspect () {2176 -1 return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';2177 -1 };2178 -12179 -1 /*2180 -12181 -1 var zeros = [];2182 -1 var groupSizes = [];2183 -1 var groupBases = [];2184 -12185 -1 var s = '';2186 -1 var i = -1;2187 -1 while (++i < BN.wordSize) {2188 -1 zeros[i] = s;2189 -1 s += '0';2190 -1 }2191 -1 groupSizes[0] = 0;2192 -1 groupSizes[1] = 0;2193 -1 groupBases[0] = 0;2194 -1 groupBases[1] = 0;2195 -1 var base = 2 - 1;2196 -1 while (++base < 36 + 1) {2197 -1 var groupSize = 0;2198 -1 var groupBase = 1;2199 -1 while (groupBase < (1 << BN.wordSize) / base) {2200 -1 groupBase *= base;2201 -1 groupSize += 1;2202 -1 }2203 -1 groupSizes[base] = groupSize;2204 -1 groupBases[base] = groupBase;-1 1274 } else if (obj.selectorText) { -1 1275 return obj.selectorText; 2205 1276 } 2206 12772207 -1 */-1 1278 return ''; -1 1279 }; 2208 12802209 -1 var zeros = [2210 -1 '',2211 -1 '0',2212 -1 '00',2213 -1 '000',2214 -1 '0000',2215 -1 '00000',2216 -1 '000000',2217 -1 '0000000',2218 -1 '00000000',2219 -1 '000000000',2220 -1 '0000000000',2221 -1 '00000000000',2222 -1 '000000000000',2223 -1 '0000000000000',2224 -1 '00000000000000',2225 -1 '000000000000000',2226 -1 '0000000000000000',2227 -1 '00000000000000000',2228 -1 '000000000000000000',2229 -1 '0000000000000000000',2230 -1 '00000000000000000000',2231 -1 '000000000000000000000',2232 -1 '0000000000000000000000',2233 -1 '00000000000000000000000',2234 -1 '000000000000000000000000',2235 -1 '0000000000000000000000000'2236 -1 ];2237 -12238 -1 var groupSizes = [2239 -1 0, 0,2240 -1 25, 16, 12, 11, 10, 9, 8,2241 -1 8, 7, 7, 7, 7, 6, 6,2242 -1 6, 6, 6, 6, 6, 5, 5,2243 -1 5, 5, 5, 5, 5, 5, 5,2244 -1 5, 5, 5, 5, 5, 5, 52245 -1 ];2246 -12247 -1 var groupBases = [2248 -1 0, 0,2249 -1 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,2250 -1 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,2251 -1 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,2252 -1 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,2253 -1 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 604661762254 -1 ];2255 -12256 -1 BN.prototype.toString = function toString (base, padding) {2257 -1 base = base || 10;2258 -1 padding = padding | 0 || 1;2259 -12260 -1 var out;2261 -1 if (base === 16 || base === 'hex') {2262 -1 out = '';2263 -1 var off = 0;2264 -1 var carry = 0;2265 -1 for (var i = 0; i < this.length; i++) {2266 -1 var w = this.words[i];2267 -1 var word = (((w << off) | carry) & 0xffffff).toString(16);2268 -1 carry = (w >>> (24 - off)) & 0xffffff;2269 -1 if (carry !== 0 || i !== this.length - 1) {2270 -1 out = zeros[6 - word.length] + word + out;2271 -1 } else {2272 -1 out = word + out;2273 -1 }2274 -1 off += 2;2275 -1 if (off >= 26) {2276 -1 off -= 26;2277 -1 i--;-1 1281 /** -1 1282 * Gets elements that refer to this element in an ARIA attribute that takes an ID reference list or -1 1283 * single ID reference. -1 1284 * @param {Element} element a potential referent. -1 1285 * @param {string=} opt_attributeName Name of an ARIA attribute to limit the results to, e.g. 'aria-owns'. -1 1286 * @return {NodeList} The elements that refer to this element or null. -1 1287 */ -1 1288 axs.utils.getAriaIdReferrers = function(element, opt_attributeName) { -1 1289 var propertyToSelector = function(propertyKey) { -1 1290 var propertyDetails = axs.constants.ARIA_PROPERTIES[propertyKey]; -1 1291 if (propertyDetails) { -1 1292 if (propertyDetails.valueType === ('idref')) { -1 1293 return '[aria-' + propertyKey + '=\'' + id + '\']'; -1 1294 } else if (propertyDetails.valueType === ('idref_list')) { -1 1295 return '[aria-' + propertyKey + '~=\'' + id + '\']'; -1 1296 } 2278 1297 }2279 -1 }2280 -1 if (carry !== 0) {2281 -1 out = carry.toString(16) + out;2282 -1 }2283 -1 while (out.length % padding !== 0) {2284 -1 out = '0' + out;2285 -1 }2286 -1 if (this.negative !== 0) {2287 -1 out = '-' + out;2288 -1 }2289 -1 return out;2290 -1 }-1 1298 return ''; -1 1299 }; -1 1300 if (!element) -1 1301 return null; -1 1302 var id = element.id; -1 1303 if (!id) -1 1304 return null; -1 1305 id = id.replace(/'/g, "\\'"); // make it safe to use in a selector 2291 13062292 -1 if (base === (base | 0) && base >= 2 && base <= 36) {2293 -1 // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));2294 -1 var groupSize = groupSizes[base];2295 -1 // var groupBase = Math.pow(base, groupSize);2296 -1 var groupBase = groupBases[base];2297 -1 out = '';2298 -1 var c = this.clone();2299 -1 c.negative = 0;2300 -1 while (!c.isZero()) {2301 -1 var r = c.modn(groupBase).toString(base);2302 -1 c = c.idivn(groupBase);2303 -12304 -1 if (!c.isZero()) {2305 -1 out = zeros[groupSize - r.length] + r + out;2306 -1 } else {2307 -1 out = r + out;-1 1307 if (opt_attributeName) { -1 1308 var propertyKey = opt_attributeName.replace(/^aria-/, ''); -1 1309 var referrerQuery = propertyToSelector(propertyKey); -1 1310 if (referrerQuery) { -1 1311 return element.ownerDocument.querySelectorAll(referrerQuery); 2308 1312 }2309 -1 }2310 -1 if (this.isZero()) {2311 -1 out = '0' + out;2312 -1 }2313 -1 while (out.length % padding !== 0) {2314 -1 out = '0' + out;2315 -1 }2316 -1 if (this.negative !== 0) {2317 -1 out = '-' + out;2318 -1 }2319 -1 return out;2320 -1 }2321 -12322 -1 assert(false, 'Base should be between 2 and 36');2323 -1 };2324 -12325 -1 BN.prototype.toNumber = function toNumber () {2326 -1 var ret = this.words[0];2327 -1 if (this.length === 2) {2328 -1 ret += this.words[1] * 0x4000000;2329 -1 } else if (this.length === 3 && this.words[2] === 0x01) {2330 -1 // NOTE: at this stage it is known that the top bit is set2331 -1 ret += 0x10000000000000 + (this.words[1] * 0x4000000);2332 -1 } else if (this.length > 2) {2333 -1 assert(false, 'Number can only safely store up to 53 bits');2334 -1 }2335 -1 return (this.negative !== 0) ? -ret : ret;2336 -1 };2337 -12338 -1 BN.prototype.toJSON = function toJSON () {2339 -1 return this.toString(16);2340 -1 };2341 -12342 -1 BN.prototype.toBuffer = function toBuffer (endian, length) {2343 -1 assert(typeof Buffer !== 'undefined');2344 -1 return this.toArrayLike(Buffer, endian, length);2345 -1 };2346 -12347 -1 BN.prototype.toArray = function toArray (endian, length) {2348 -1 return this.toArrayLike(Array, endian, length);2349 -1 };2350 -12351 -1 BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {2352 -1 var byteLength = this.byteLength();2353 -1 var reqLength = length || Math.max(1, byteLength);2354 -1 assert(byteLength <= reqLength, 'byte array longer than desired length');2355 -1 assert(reqLength > 0, 'Requested array length <= 0');2356 -12357 -1 this.strip();2358 -1 var littleEndian = endian === 'le';2359 -1 var res = new ArrayType(reqLength);2360 -12361 -1 var b, i;2362 -1 var q = this.clone();2363 -1 if (!littleEndian) {2364 -1 // Assume big-endian2365 -1 for (i = 0; i < reqLength - byteLength; i++) {2366 -1 res[i] = 0;2367 -1 }2368 -12369 -1 for (i = 0; !q.isZero(); i++) {2370 -1 b = q.andln(0xff);2371 -1 q.iushrn(8);2372 -12373 -1 res[reqLength - i - 1] = b;2374 -1 }2375 1313 } else {2376 -1 for (i = 0; !q.isZero(); i++) {2377 -1 b = q.andln(0xff);2378 -1 q.iushrn(8);2379 -12380 -1 res[i] = b;2381 -1 }2382 -12383 -1 for (; i < reqLength; i++) {2384 -1 res[i] = 0;2385 -1 }2386 -1 }2387 -12388 -1 return res;2389 -1 };2390 -12391 -1 if (Math.clz32) {2392 -1 BN.prototype._countBits = function _countBits (w) {2393 -1 return 32 - Math.clz32(w);2394 -1 };2395 -1 } else {2396 -1 BN.prototype._countBits = function _countBits (w) {2397 -1 var t = w;2398 -1 var r = 0;2399 -1 if (t >= 0x1000) {2400 -1 r += 13;2401 -1 t >>>= 13;2402 -1 }2403 -1 if (t >= 0x40) {2404 -1 r += 7;2405 -1 t >>>= 7;2406 -1 }2407 -1 if (t >= 0x8) {2408 -1 r += 4;2409 -1 t >>>= 4;2410 -1 }2411 -1 if (t >= 0x02) {2412 -1 r += 2;2413 -1 t >>>= 2;2414 -1 }2415 -1 return r + t;2416 -1 };2417 -1 }2418 -12419 -1 BN.prototype._zeroBits = function _zeroBits (w) {2420 -1 // Short-cut2421 -1 if (w === 0) return 26;2422 -12423 -1 var t = w;2424 -1 var r = 0;2425 -1 if ((t & 0x1fff) === 0) {2426 -1 r += 13;2427 -1 t >>>= 13;2428 -1 }2429 -1 if ((t & 0x7f) === 0) {2430 -1 r += 7;2431 -1 t >>>= 7;2432 -1 }2433 -1 if ((t & 0xf) === 0) {2434 -1 r += 4;2435 -1 t >>>= 4;2436 -1 }2437 -1 if ((t & 0x3) === 0) {2438 -1 r += 2;2439 -1 t >>>= 2;2440 -1 }2441 -1 if ((t & 0x1) === 0) {2442 -1 r++;-1 1314 var selectors = []; -1 1315 for (var propertyKey in axs.constants.ARIA_PROPERTIES) { -1 1316 var referrerQuery = propertyToSelector(propertyKey); -1 1317 if (referrerQuery) { -1 1318 selectors.push(referrerQuery); -1 1319 } -1 1320 } -1 1321 return element.ownerDocument.querySelectorAll(selectors.join(',')); 2443 1322 }2444 -1 return r;2445 -1 };2446 -12447 -1 // Return number of used bits in a BN2448 -1 BN.prototype.bitLength = function bitLength () {2449 -1 var w = this.words[this.length - 1];2450 -1 var hi = this._countBits(w);2451 -1 return (this.length - 1) * 26 + hi;2452 -1 };2453 -12454 -1 function toBitArray (num) {2455 -1 var w = new Array(num.bitLength());-1 1323 return null; -1 1324 }; 2456 13252457 -1 for (var bit = 0; bit < w.length; bit++) {2458 -1 var off = (bit / 26) | 0;2459 -1 var wbit = bit % 26;-1 1326 /** -1 1327 * Gets elements that refer to this element in an HTML attribute that takes an ID reference list or -1 1328 * single ID reference. -1 1329 * @param {Element} element a potential referent. -1 1330 * @return {NodeList} The elements that refer to this element. -1 1331 */ -1 1332 axs.utils.getHtmlIdReferrers = function(element) { -1 1333 if (!element) -1 1334 return null; -1 1335 var id = element.id; -1 1336 if (!id) -1 1337 return null; -1 1338 id = id.replace(/'/g, "\\'"); // make it safe to use in a selector -1 1339 var selectorTemplates = [ -1 1340 '[contextmenu=\'{id}\']', -1 1341 '[itemref~=\'{id}\']', -1 1342 'button[form=\'{id}\']', -1 1343 'button[menu=\'{id}\']', -1 1344 'fieldset[form=\'{id}\']', -1 1345 'input[form=\'{id}\']', -1 1346 'input[list=\'{id}\']', -1 1347 'keygen[form=\'{id}\']', -1 1348 'label[for=\'{id}\']', -1 1349 'label[form=\'{id}\']', -1 1350 'menuitem[command=\'{id}\']', -1 1351 'object[form=\'{id}\']', -1 1352 'output[for~=\'{id}\']', -1 1353 'output[form=\'{id}\']', -1 1354 'select[form=\'{id}\']', -1 1355 'td[headers~=\'{id}\']', -1 1356 'textarea[form=\'{id}\']', -1 1357 'tr[headers~=\'{id}\']']; -1 1358 var selectors = selectorTemplates.map(function(selector) { -1 1359 return selector.replace('\{id\}', id); -1 1360 }); -1 1361 return element.ownerDocument.querySelectorAll(selectors.join(',')); -1 1362 }; 2460 13632461 -1 w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;-1 1364 /** -1 1365 * Gets a list of all IDs this element references in either ARIA or HTML attributes. -1 1366 * -1 1367 * @param {Element} element The element to check for idref attributes. -1 1368 * @returns {Array.<string>} Any IDs this element references. -1 1369 */ -1 1370 axs.utils.getReferencedIds = function(element) { -1 1371 var result = []; -1 1372 var addResult = function(ids) { -1 1373 if (ids) { -1 1374 if (ids.indexOf(' ') > 0) { -1 1375 result = result.concat(attrib.value.split(' ')); -1 1376 } else { -1 1377 result.push(ids); -1 1378 } -1 1379 } -1 1380 }; -1 1381 for (var i = 0; i < element.attributes.length; i++) { -1 1382 var tagName = element.tagName.toLowerCase(); -1 1383 var attrib = element.attributes[i]; -1 1384 if (attrib.specified) { -1 1385 var attribName = attrib.name; -1 1386 var ariaAttr = attribName.match(/aria-(.+)/); -1 1387 if (ariaAttr) { -1 1388 var details = axs.constants.ARIA_PROPERTIES[ariaAttr[1]]; -1 1389 if (details && (details.valueType === ('idref') || details.valueType === ('idref_list'))) { -1 1390 addResult(attrib.value); -1 1391 } -1 1392 continue; -1 1393 } -1 1394 switch (attribName) { -1 1395 case 'contextmenu': -1 1396 case 'itemref': -1 1397 addResult(attrib.value); -1 1398 break; -1 1399 case 'form': -1 1400 if (tagName == 'button' || tagName == 'fieldset' || tagName == 'input' || -1 1401 tagName == 'keygen' || tagName == 'label' || tagName == 'object' || -1 1402 tagName == 'output' || tagName == 'select' || tagName == 'textarea') { -1 1403 addResult(attrib.value); -1 1404 } -1 1405 break; -1 1406 case 'for': -1 1407 if (tagName == 'label' || tagName == 'output') { -1 1408 addResult(attrib.value); -1 1409 } -1 1410 break; -1 1411 case 'menu': -1 1412 if (tagName == 'button') { -1 1413 addResult(attrib.value); -1 1414 } -1 1415 break; -1 1416 case 'list': -1 1417 if (tagName == 'input') { -1 1418 addResult(attrib.value); -1 1419 } -1 1420 break; -1 1421 case 'command': -1 1422 if (tagName == 'menuitem') { -1 1423 addResult(attrib.value); -1 1424 } -1 1425 break; -1 1426 case 'headers': -1 1427 if (tagName == 'td' || tagName == 'tr') { -1 1428 addResult(attrib.value); -1 1429 } -1 1430 break; -1 1431 } -1 1432 } 2462 1433 } -1 1434 return result; -1 1435 }; 2463 14362464 -1 return w;2465 -1 }2466 -12467 -1 // Number of trailing zero bits2468 -1 BN.prototype.zeroBits = function zeroBits () {2469 -1 if (this.isZero()) return 0;2470 -12471 -1 var r = 0;2472 -1 for (var i = 0; i < this.length; i++) {2473 -1 var b = this._zeroBits(this.words[i]);2474 -1 r += b;2475 -1 if (b !== 26) break;-1 1437 /** -1 1438 * Gets elements that refer to this element in an attribute that takes an ID reference list or -1 1439 * single ID reference. -1 1440 * @param {Element} element a potential referent. -1 1441 * @return {Array<Element>} The elements that refer to this element. -1 1442 */ -1 1443 axs.utils.getIdReferrers = function(element) { -1 1444 var result = []; -1 1445 var referrers = axs.utils.getHtmlIdReferrers(element); -1 1446 if (referrers) { -1 1447 result = result.concat(Array.prototype.slice.call(referrers)); 2476 1448 }2477 -1 return r;2478 -1 };2479 -12480 -1 BN.prototype.byteLength = function byteLength () {2481 -1 return Math.ceil(this.bitLength() / 8);2482 -1 };2483 -12484 -1 BN.prototype.toTwos = function toTwos (width) {2485 -1 if (this.negative !== 0) {2486 -1 return this.abs().inotn(width).iaddn(1);-1 1449 referrers = axs.utils.getAriaIdReferrers(element); -1 1450 if (referrers) { -1 1451 result = result.concat(Array.prototype.slice.call(referrers)); 2487 1452 }2488 -1 return this.clone();2489 -1 };-1 1453 return result; -1 1454 }; 2490 14552491 -1 BN.prototype.fromTwos = function fromTwos (width) {2492 -1 if (this.testn(width - 1)) {2493 -1 return this.notn(width).iaddn(1).ineg();-1 1456 /** -1 1457 * Gets elements which this element refers to in the given attribute. -1 1458 * @param {!string} attributeName Name of an ARIA attribute, e.g. 'aria-owns'. -1 1459 * @param {Element} element The DOM element which has the ARIA attribute. -1 1460 * @return {!Array.<Element>} An array of elements that are referred to by this element. -1 1461 * @example -1 1462 * var owner = document.body.appendChild(document.createElement("div")); -1 1463 * var owned = document.body.appendChild(document.createElement("div")); -1 1464 * owner.setAttribute("aria-owns", "kungfu"); -1 1465 * owned.setAttribute("id", "kungfu"); -1 1466 * console.log(axs.utils.getIdReferents("aria-owns", owner)[0] === owned); // This will log 'true' -1 1467 */ -1 1468 axs.utils.getIdReferents = function(attributeName, element) { -1 1469 var result = []; -1 1470 var propertyKey = attributeName.replace(/^aria-/, ''); -1 1471 var property = axs.constants.ARIA_PROPERTIES[propertyKey]; -1 1472 if (!property || !element.hasAttribute(attributeName)) -1 1473 return result; -1 1474 var propertyType = property.valueType; -1 1475 if (propertyType === 'idref_list' || propertyType === 'idref') { -1 1476 var ownerDocument = element.ownerDocument; -1 1477 var ids = element.getAttribute(attributeName); -1 1478 ids = ids.split(/\s+/); -1 1479 for (var i = 0, len = ids.length; i < len; i++) { -1 1480 var next = ownerDocument.getElementById(ids[i]); -1 1481 if (next) { -1 1482 result[result.length] = next; -1 1483 } -1 1484 } 2494 1485 }2495 -1 return this.clone();2496 -1 };2497 -12498 -1 BN.prototype.isNeg = function isNeg () {2499 -1 return this.negative !== 0;2500 -1 };2501 -12502 -1 // Return negative clone of `this`2503 -1 BN.prototype.neg = function neg () {2504 -1 return this.clone().ineg();2505 -1 };-1 1486 return result; -1 1487 }; 2506 14882507 -1 BN.prototype.ineg = function ineg () {2508 -1 if (!this.isZero()) {2509 -1 this.negative ^= 1;-1 1489 /** -1 1490 * Gets a subset of 'axs.constants.ARIA_PROPERTIES' filtered by 'valueType'. -1 1491 * @param {!Array.<string>} valueTypes Types to match, e.g. ['idref_list']. -1 1492 * @return {Object.<string, Object>} axs.constants.ARIA_PROPERTIES which match. -1 1493 */ -1 1494 axs.utils.getAriaPropertiesByValueType = function(valueTypes) { -1 1495 var result = {}; -1 1496 for (var propertyName in axs.constants.ARIA_PROPERTIES) { -1 1497 var property = axs.constants.ARIA_PROPERTIES[propertyName]; -1 1498 if (property && valueTypes.indexOf(property.valueType) >= 0) { -1 1499 result[propertyName] = property; -1 1500 } 2510 1501 } -1 1502 return result; -1 1503 }; 2511 15042512 -1 return this;2513 -1 };-1 1505 /** -1 1506 * Builds a selector that matches an element with any of these ARIA properties. -1 1507 * @param {Object.<string, Object>} ariaProperties axs.constants.ARIA_PROPERTIES -1 1508 * @return {!string} The selector. -1 1509 */ -1 1510 axs.utils.getSelectorForAriaProperties = function(ariaProperties) { -1 1511 var propertyNames = Object.keys(/** @type {!Object} */(ariaProperties)); -1 1512 var result = propertyNames.map(function(propertyName) { -1 1513 return '[aria-' + propertyName + ']'; -1 1514 }); -1 1515 result.sort(); // facilitates reading long selectors and unit testing -1 1516 return result.join(','); -1 1517 }; 2514 15182515 -1 // Or `num` with `this` in-place2516 -1 BN.prototype.iuor = function iuor (num) {2517 -1 while (this.length < num.length) {2518 -1 this.words[this.length++] = 0;-1 1519 /** -1 1520 * Finds descendants of this element which implement the given ARIA role. -1 1521 * Will look for descendants with implicit or explicit role. -1 1522 * @param {Element} element an HTML DOM element. -1 1523 * @param {string} role The role you seek. -1 1524 * @return {!Array.<Element>} An array of matching elements. -1 1525 * @example -1 1526 * var container = document.createElement("div"); -1 1527 * var button = document.createElement("button"); -1 1528 * var span = document.createElement("span"); -1 1529 * span.setAttribute("role", "button"); -1 1530 * container.appendChild(button); -1 1531 * container.appendChild(span); -1 1532 * var result = axs.utils.findDescendantsWithRole(container, "button"); // result is an array containing both 'button' and 'span' -1 1533 */ -1 1534 axs.utils.findDescendantsWithRole = function(element, role) { -1 1535 if (!(element && role)) -1 1536 return []; -1 1537 var selector = axs.properties.getSelectorForRole(role); -1 1538 if (!selector) -1 1539 return []; -1 1540 var result = element.querySelectorAll(selector); -1 1541 if (result) { // Convert NodeList to Array; methinks 80/20 that's what callers want. -1 1542 result = Array.prototype.map.call(result, function(item) { return item; }); -1 1543 } else { -1 1544 return []; 2519 1545 } -1 1546 return result; -1 1547 }; 2520 15482521 -1 for (var i = 0; i < num.length; i++) {2522 -1 this.words[i] = this.words[i] | num.words[i];2523 -1 }-1 1549 },{}],4:[function(require,module,exports){ -1 1550 // Copyright 2013 Google Inc. -1 1551 // -1 1552 // Licensed under the Apache License, Version 2.0 (the "License"); -1 1553 // you may not use this file except in compliance with the License. -1 1554 // You may obtain a copy of the License at -1 1555 // -1 1556 // http://www.apache.org/licenses/LICENSE-2.0 -1 1557 // -1 1558 // Unless required by applicable law or agreed to in writing, software -1 1559 // distributed under the License is distributed on an "AS IS" BASIS, -1 1560 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -1 1561 // See the License for the specific language governing permissions and -1 1562 // limitations under the License. 2524 15632525 -1 return this.strip();2526 -1 };-1 1564 goog.provide('axs.browserUtils'); 2527 15652528 -1 BN.prototype.ior = function ior (num) {2529 -1 assert((this.negative | num.negative) === 0);2530 -1 return this.iuor(num);2531 -1 };-1 1566 /** -1 1567 * Use Webkit matcher when matches() is not supported. -1 1568 * Use Firefox matcher when Webkit is not supported. -1 1569 * Use IE matcher when neither webkit nor Firefox supported. -1 1570 * @param {Element} element -1 1571 * @param {string} selector -1 1572 * @return {boolean} true if the element matches the selector -1 1573 */ -1 1574 axs.browserUtils.matchSelector = function(element, selector) { -1 1575 if (element.matches) -1 1576 return element.matches(selector); -1 1577 if (element.webkitMatchesSelector) -1 1578 return element.webkitMatchesSelector(selector); -1 1579 if (element.mozMatchesSelector) -1 1580 return element.mozMatchesSelector(selector); -1 1581 if (element.msMatchesSelector) -1 1582 return element.msMatchesSelector(selector); -1 1583 return false; -1 1584 }; 2532 15852533 -1 // Or `num` with `this`2534 -1 BN.prototype.or = function or (num) {2535 -1 if (this.length > num.length) return this.clone().ior(num);2536 -1 return num.clone().ior(this);2537 -1 };-1 1586 },{}],5:[function(require,module,exports){ -1 1587 // Copyright 2015 Google Inc. -1 1588 // -1 1589 // Licensed under the Apache License, Version 2.0 (the "License"); -1 1590 // you may not use this file except in compliance with the License. -1 1591 // You may obtain a copy of the License at -1 1592 // -1 1593 // http://www.apache.org/licenses/LICENSE-2.0 -1 1594 // -1 1595 // Unless required by applicable law or agreed to in writing, software -1 1596 // distributed under the License is distributed on an "AS IS" BASIS, -1 1597 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -1 1598 // See the License for the specific language governing permissions and -1 1599 // limitations under the License. 2538 16002539 -1 BN.prototype.uor = function uor (num) {2540 -1 if (this.length > num.length) return this.clone().iuor(num);2541 -1 return num.clone().iuor(this);2542 -1 };-1 1601 goog.provide('axs.color'); -1 1602 goog.provide('axs.color.Color'); 2543 16032544 -1 // And `num` with `this` in-place2545 -1 BN.prototype.iuand = function iuand (num) {2546 -1 // b = min-length(num, this)2547 -1 var b;2548 -1 if (this.length > num.length) {2549 -1 b = num;2550 -1 } else {2551 -1 b = this;2552 -1 }-1 1604 /** -1 1605 * @constructor -1 1606 * @param {number} red -1 1607 * @param {number} green -1 1608 * @param {number} blue -1 1609 * @param {number} alpha -1 1610 */ -1 1611 axs.color.Color = function(red, green, blue, alpha) { -1 1612 /** @type {number} */ -1 1613 this.red = red; 2553 16142554 -1 for (var i = 0; i < b.length; i++) {2555 -1 this.words[i] = this.words[i] & num.words[i];2556 -1 }-1 1615 /** @type {number} */ -1 1616 this.green = green; 2557 16172558 -1 this.length = b.length;-1 1618 /** @type {number} */ -1 1619 this.blue = blue; 2559 16202560 -1 return this.strip();2561 -1 };-1 1621 /** @type {number} */ -1 1622 this.alpha = alpha; -1 1623 }; 2562 16242563 -1 BN.prototype.iand = function iand (num) {2564 -1 assert((this.negative | num.negative) === 0);2565 -1 return this.iuand(num);2566 -1 };-1 1625 /** -1 1626 * @constructor -1 1627 * See https://en.wikipedia.org/wiki/YCbCr for more information. -1 1628 * @param {Array.<number>} coords The YCbCr values as a 3 element array, in the order [luma, Cb, Cr]. -1 1629 * All numbers are in the range [0, 1]. -1 1630 */ -1 1631 axs.color.YCbCr = function(coords) { -1 1632 /** @type {number} */ -1 1633 this.luma = this.z = coords[0]; 2567 16342568 -1 // And `num` with `this`2569 -1 BN.prototype.and = function and (num) {2570 -1 if (this.length > num.length) return this.clone().iand(num);2571 -1 return num.clone().iand(this);2572 -1 };-1 1635 /** @type {number} */ -1 1636 this.Cb = this.x = coords[1]; 2573 16372574 -1 BN.prototype.uand = function uand (num) {2575 -1 if (this.length > num.length) return this.clone().iuand(num);2576 -1 return num.clone().iuand(this);2577 -1 };-1 1638 /** @type {number} */ -1 1639 this.Cr = this.y = coords[2]; -1 1640 }; 2578 16412579 -1 // Xor `num` with `this` in-place2580 -1 BN.prototype.iuxor = function iuxor (num) {2581 -1 // a.length > b.length2582 -1 var a;2583 -1 var b;2584 -1 if (this.length > num.length) {2585 -1 a = this;2586 -1 b = num;2587 -1 } else {2588 -1 a = num;2589 -1 b = this;2590 -1 }-1 1642 axs.color.YCbCr.prototype = { -1 1643 /** -1 1644 * @param {number} scalar -1 1645 * @return {axs.color.YCbCr} This color multiplied by the given scalar -1 1646 */ -1 1647 multiply: function(scalar) { -1 1648 var result = [ this.luma * scalar, this.Cb * scalar, this.Cr * scalar ]; -1 1649 return new axs.color.YCbCr(result); -1 1650 }, 2591 16512592 -1 for (var i = 0; i < b.length; i++) {2593 -1 this.words[i] = a.words[i] ^ b.words[i];2594 -1 }-1 1652 /** -1 1653 * @param {axs.color.YCbCr} other -1 1654 * @return {axs.color.YCbCr} This plus other -1 1655 */ -1 1656 add: function(other) { -1 1657 var result = [ this.luma + other.luma, this.Cb + other.Cb, this.Cr + other.Cr ]; -1 1658 return new axs.color.YCbCr(result); -1 1659 }, 2595 16602596 -1 if (this !== a) {2597 -1 for (; i < a.length; i++) {2598 -1 this.words[i] = a.words[i];2599 -1 }-1 1661 /** -1 1662 * @param {axs.color.YCbCr} other -1 1663 * @return {axs.color.YCbCr} This minus other -1 1664 */ -1 1665 subtract: function(other) { -1 1666 var result = [ this.luma - other.luma, this.Cb - other.Cb, this.Cr - other.Cr ]; -1 1667 return new axs.color.YCbCr(result); 2600 1668 } 2601 16692602 -1 this.length = a.length;2603 -12604 -1 return this.strip();2605 -1 };-1 1670 }; 2606 16712607 -1 BN.prototype.ixor = function ixor (num) {2608 -1 assert((this.negative | num.negative) === 0);2609 -1 return this.iuxor(num);2610 -1 };2611 16722612 -1 // Xor `num` with `this`2613 -1 BN.prototype.xor = function xor (num) {2614 -1 if (this.length > num.length) return this.clone().ixor(num);2615 -1 return num.clone().ixor(this);2616 -1 };-1 1673 /** -1 1674 * Calculate the contrast ratio between the two given colors. Returns the ratio -1 1675 * to 1, for example for two two colors with a contrast ratio of 21:1, this -1 1676 * function will return 21. -1 1677 * @param {axs.color.Color} fgColor -1 1678 * @param {axs.color.Color} bgColor -1 1679 * @return {!number} -1 1680 */ -1 1681 axs.color.calculateContrastRatio = function(fgColor, bgColor) { -1 1682 if (fgColor.alpha < 1) -1 1683 fgColor = axs.color.flattenColors(fgColor, bgColor); 2617 16842618 -1 BN.prototype.uxor = function uxor (num) {2619 -1 if (this.length > num.length) return this.clone().iuxor(num);2620 -1 return num.clone().iuxor(this);2621 -1 };-1 1685 var fgLuminance = axs.color.calculateLuminance(fgColor); -1 1686 var bgLuminance = axs.color.calculateLuminance(bgColor); -1 1687 var contrastRatio = (Math.max(fgLuminance, bgLuminance) + 0.05) / -1 1688 (Math.min(fgLuminance, bgLuminance) + 0.05); -1 1689 return contrastRatio; -1 1690 }; 2622 16912623 -1 // Not ``this`` with ``width`` bitwidth2624 -1 BN.prototype.inotn = function inotn (width) {2625 -1 assert(typeof width === 'number' && width >= 0);-1 1692 /** -1 1693 * Calculate the luminance of the given color using the WCAG algorithm. -1 1694 * @param {axs.color.Color} color -1 1695 * @return {number} -1 1696 */ -1 1697 axs.color.calculateLuminance = function(color) { -1 1698 /* var rSRGB = color.red / 255; -1 1699 var gSRGB = color.green / 255; -1 1700 var bSRGB = color.blue / 255; 2626 17012627 -1 var bytesNeeded = Math.ceil(width / 26) | 0;2628 -1 var bitsLeft = width % 26;-1 1702 var r = rSRGB <= 0.03928 ? rSRGB / 12.92 : Math.pow(((rSRGB + 0.055)/1.055), 2.4); -1 1703 var g = gSRGB <= 0.03928 ? gSRGB / 12.92 : Math.pow(((gSRGB + 0.055)/1.055), 2.4); -1 1704 var b = bSRGB <= 0.03928 ? bSRGB / 12.92 : Math.pow(((bSRGB + 0.055)/1.055), 2.4); 2629 17052630 -1 // Extend the buffer with leading zeroes2631 -1 this._expand(bytesNeeded);-1 1706 return 0.2126 * r + 0.7152 * g + 0.0722 * b; */ -1 1707 var ycc = axs.color.toYCbCr(color); -1 1708 return ycc.luma; -1 1709 }; 2632 17102633 -1 if (bitsLeft > 0) {2634 -1 bytesNeeded--;2635 -1 }-1 1711 /** -1 1712 * Compute the luminance ratio between two luminance values. -1 1713 * @param {number} luminance1 -1 1714 * @param {number} luminance2 -1 1715 */ -1 1716 axs.color.luminanceRatio = function(luminance1, luminance2) { -1 1717 return (Math.max(luminance1, luminance2) + 0.05) / -1 1718 (Math.min(luminance1, luminance2) + 0.05); -1 1719 }; 2636 17202637 -1 // Handle complete words2638 -1 for (var i = 0; i < bytesNeeded; i++) {2639 -1 this.words[i] = ~this.words[i] & 0x3ffffff;-1 1721 /** -1 1722 * @param {string} colorString The color string from CSS. -1 1723 * @return {?axs.color.Color} -1 1724 */ -1 1725 axs.color.parseColor = function(colorString) { -1 1726 if (colorString === "transparent") { -1 1727 return new axs.color.Color(0, 0, 0, 0); 2640 1728 } -1 1729 var rgbRegex = /^rgb\((\d+), (\d+), (\d+)\)$/; -1 1730 var match = colorString.match(rgbRegex); 2641 17312642 -1 // Handle the residue2643 -1 if (bitsLeft > 0) {2644 -1 this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));-1 1732 if (match) { -1 1733 var r = parseInt(match[1], 10); -1 1734 var g = parseInt(match[2], 10); -1 1735 var b = parseInt(match[3], 10); -1 1736 var a = 1; -1 1737 return new axs.color.Color(r, g, b, a); 2645 1738 } 2646 17392647 -1 // And remove leading zeroes2648 -1 return this.strip();2649 -1 };2650 -12651 -1 BN.prototype.notn = function notn (width) {2652 -1 return this.clone().inotn(width);2653 -1 };2654 -12655 -1 // Set `bit` of `this`2656 -1 BN.prototype.setn = function setn (bit, val) {2657 -1 assert(typeof bit === 'number' && bit >= 0);2658 -12659 -1 var off = (bit / 26) | 0;2660 -1 var wbit = bit % 26;2661 -12662 -1 this._expand(off + 1);2663 -12664 -1 if (val) {2665 -1 this.words[off] = this.words[off] | (1 << wbit);2666 -1 } else {2667 -1 this.words[off] = this.words[off] & ~(1 << wbit);-1 1740 var rgbaRegex = /^rgba\((\d+), (\d+), (\d+), (\d*(\.\d+)?)\)/; -1 1741 match = colorString.match(rgbaRegex); -1 1742 if (match) { -1 1743 var r = parseInt(match[1], 10); -1 1744 var g = parseInt(match[2], 10); -1 1745 var b = parseInt(match[3], 10); -1 1746 var a = parseFloat(match[4]); -1 1747 return new axs.color.Color(r, g, b, a); 2668 1748 } 2669 17492670 -1 return this.strip();2671 -1 };-1 1750 return null; -1 1751 }; 2672 17522673 -1 // Add `num` to `this` in-place2674 -1 BN.prototype.iadd = function iadd (num) {2675 -1 var r;2676 -12677 -1 // negative + positive2678 -1 if (this.negative !== 0 && num.negative === 0) {2679 -1 this.negative = 0;2680 -1 r = this.isub(num);2681 -1 this.negative ^= 1;2682 -1 return this._normSign();2683 -12684 -1 // positive + negative2685 -1 } else if (this.negative === 0 && num.negative !== 0) {2686 -1 num.negative = 0;2687 -1 r = this.isub(num);2688 -1 num.negative = 1;2689 -1 return r._normSign();2690 -1 }2691 -12692 -1 // a.length > b.length2693 -1 var a, b;2694 -1 if (this.length > num.length) {2695 -1 a = this;2696 -1 b = num;2697 -1 } else {2698 -1 a = num;2699 -1 b = this;2700 -1 }-1 1753 /** -1 1754 * @param {number} value The value of a color channel, 0 <= value <= 0xFF -1 1755 * @return {!string} -1 1756 */ -1 1757 axs.color.colorChannelToString = function(value) { -1 1758 value = Math.round(value); -1 1759 if (value <= 0xF) -1 1760 return '0' + value.toString(16); -1 1761 return value.toString(16); -1 1762 }; 2701 17632702 -1 var carry = 0;2703 -1 for (var i = 0; i < b.length; i++) {2704 -1 r = (a.words[i] | 0) + (b.words[i] | 0) + carry;2705 -1 this.words[i] = r & 0x3ffffff;2706 -1 carry = r >>> 26;2707 -1 }2708 -1 for (; carry !== 0 && i < a.length; i++) {2709 -1 r = (a.words[i] | 0) + carry;2710 -1 this.words[i] = r & 0x3ffffff;2711 -1 carry = r >>> 26;-1 1764 /** -1 1765 * @param {axs.color.Color} color -1 1766 * @return {!string} -1 1767 */ -1 1768 axs.color.colorToString = function(color) { -1 1769 if (color.alpha == 1) { -1 1770 return '#' + axs.color.colorChannelToString(color.red) + -1 1771 axs.color.colorChannelToString(color.green) + axs.color.colorChannelToString(color.blue); 2712 1772 } -1 1773 else -1 1774 return 'rgba(' + [color.red, color.green, color.blue, color.alpha].join(',') + ')'; -1 1775 }; 2713 17762714 -1 this.length = a.length;2715 -1 if (carry !== 0) {2716 -1 this.words[this.length] = carry;2717 -1 this.length++;2718 -1 // Copy the rest of the words2719 -1 } else if (a !== this) {2720 -1 for (; i < a.length; i++) {2721 -1 this.words[i] = a.words[i];2722 -1 }2723 -1 }2724 -12725 -1 return this;2726 -1 };2727 -12728 -1 // Add `num` to `this`2729 -1 BN.prototype.add = function add (num) {2730 -1 var res;2731 -1 if (num.negative !== 0 && this.negative === 0) {2732 -1 num.negative = 0;2733 -1 res = this.sub(num);2734 -1 num.negative ^= 1;2735 -1 return res;2736 -1 } else if (num.negative === 0 && this.negative !== 0) {2737 -1 this.negative = 0;2738 -1 res = num.sub(this);2739 -1 this.negative = 1;2740 -1 return res;2741 -1 }2742 -12743 -1 if (this.length > num.length) return this.clone().iadd(num);2744 -12745 -1 return num.clone().iadd(this);2746 -1 };2747 -12748 -1 // Subtract `num` from `this` in-place2749 -1 BN.prototype.isub = function isub (num) {2750 -1 // this - (-num) = this + num2751 -1 if (num.negative !== 0) {2752 -1 num.negative = 0;2753 -1 var r = this.iadd(num);2754 -1 num.negative = 1;2755 -1 return r._normSign();2756 -12757 -1 // -this - num = -(this + num)2758 -1 } else if (this.negative !== 0) {2759 -1 this.negative = 0;2760 -1 this.iadd(num);2761 -1 this.negative = 1;2762 -1 return this._normSign();2763 -1 }2764 -12765 -1 // At this point both numbers are positive2766 -1 var cmp = this.cmp(num);2767 -12768 -1 // Optimization - zeroify2769 -1 if (cmp === 0) {2770 -1 this.negative = 0;2771 -1 this.length = 1;2772 -1 this.words[0] = 0;2773 -1 return this;2774 -1 }2775 -12776 -1 // a > b2777 -1 var a, b;2778 -1 if (cmp > 0) {2779 -1 a = this;2780 -1 b = num;2781 -1 } else {2782 -1 a = num;2783 -1 b = this;2784 -1 }2785 -12786 -1 var carry = 0;2787 -1 for (var i = 0; i < b.length; i++) {2788 -1 r = (a.words[i] | 0) - (b.words[i] | 0) + carry;2789 -1 carry = r >> 26;2790 -1 this.words[i] = r & 0x3ffffff;2791 -1 }2792 -1 for (; carry !== 0 && i < a.length; i++) {2793 -1 r = (a.words[i] | 0) + carry;2794 -1 carry = r >> 26;2795 -1 this.words[i] = r & 0x3ffffff;2796 -1 }2797 -12798 -1 // Copy rest of the words2799 -1 if (carry === 0 && i < a.length && a !== this) {2800 -1 for (; i < a.length; i++) {2801 -1 this.words[i] = a.words[i];2802 -1 }2803 -1 }2804 -12805 -1 this.length = Math.max(this.length, i);2806 -12807 -1 if (a !== this) {2808 -1 this.negative = 1;2809 -1 }2810 -12811 -1 return this.strip();2812 -1 };2813 -12814 -1 // Subtract `num` from `this`2815 -1 BN.prototype.sub = function sub (num) {2816 -1 return this.clone().isub(num);2817 -1 };2818 -12819 -1 function smallMulTo (self, num, out) {2820 -1 out.negative = num.negative ^ self.negative;2821 -1 var len = (self.length + num.length) | 0;2822 -1 out.length = len;2823 -1 len = (len - 1) | 0;2824 -12825 -1 // Peel one iteration (compiler can't do it, because of code complexity)2826 -1 var a = self.words[0] | 0;2827 -1 var b = num.words[0] | 0;2828 -1 var r = a * b;2829 -12830 -1 var lo = r & 0x3ffffff;2831 -1 var carry = (r / 0x4000000) | 0;2832 -1 out.words[0] = lo;2833 -12834 -1 for (var k = 1; k < len; k++) {2835 -1 // Sum all words with the same `i + j = k` and accumulate `ncarry`,2836 -1 // note that ncarry could be >= 0x3ffffff2837 -1 var ncarry = carry >>> 26;2838 -1 var rword = carry & 0x3ffffff;2839 -1 var maxJ = Math.min(k, num.length - 1);2840 -1 for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {2841 -1 var i = (k - j) | 0;2842 -1 a = self.words[i] | 0;2843 -1 b = num.words[j] | 0;2844 -1 r = a * b + rword;2845 -1 ncarry += (r / 0x4000000) | 0;2846 -1 rword = r & 0x3ffffff;2847 -1 }2848 -1 out.words[k] = rword | 0;2849 -1 carry = ncarry | 0;2850 -1 }2851 -1 if (carry !== 0) {2852 -1 out.words[k] = carry | 0;2853 -1 } else {2854 -1 out.length--;2855 -1 }2856 -12857 -1 return out.strip();2858 -1 }2859 -12860 -1 // TODO(indutny): it may be reasonable to omit it for users who don't need2861 -1 // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit2862 -1 // multiplication (like elliptic secp256k1).2863 -1 var comb10MulTo = function comb10MulTo (self, num, out) {2864 -1 var a = self.words;2865 -1 var b = num.words;2866 -1 var o = out.words;2867 -1 var c = 0;2868 -1 var lo;2869 -1 var mid;2870 -1 var hi;2871 -1 var a0 = a[0] | 0;2872 -1 var al0 = a0 & 0x1fff;2873 -1 var ah0 = a0 >>> 13;2874 -1 var a1 = a[1] | 0;2875 -1 var al1 = a1 & 0x1fff;2876 -1 var ah1 = a1 >>> 13;2877 -1 var a2 = a[2] | 0;2878 -1 var al2 = a2 & 0x1fff;2879 -1 var ah2 = a2 >>> 13;2880 -1 var a3 = a[3] | 0;2881 -1 var al3 = a3 & 0x1fff;2882 -1 var ah3 = a3 >>> 13;2883 -1 var a4 = a[4] | 0;2884 -1 var al4 = a4 & 0x1fff;2885 -1 var ah4 = a4 >>> 13;2886 -1 var a5 = a[5] | 0;2887 -1 var al5 = a5 & 0x1fff;2888 -1 var ah5 = a5 >>> 13;2889 -1 var a6 = a[6] | 0;2890 -1 var al6 = a6 & 0x1fff;2891 -1 var ah6 = a6 >>> 13;2892 -1 var a7 = a[7] | 0;2893 -1 var al7 = a7 & 0x1fff;2894 -1 var ah7 = a7 >>> 13;2895 -1 var a8 = a[8] | 0;2896 -1 var al8 = a8 & 0x1fff;2897 -1 var ah8 = a8 >>> 13;2898 -1 var a9 = a[9] | 0;2899 -1 var al9 = a9 & 0x1fff;2900 -1 var ah9 = a9 >>> 13;2901 -1 var b0 = b[0] | 0;2902 -1 var bl0 = b0 & 0x1fff;2903 -1 var bh0 = b0 >>> 13;2904 -1 var b1 = b[1] | 0;2905 -1 var bl1 = b1 & 0x1fff;2906 -1 var bh1 = b1 >>> 13;2907 -1 var b2 = b[2] | 0;2908 -1 var bl2 = b2 & 0x1fff;2909 -1 var bh2 = b2 >>> 13;2910 -1 var b3 = b[3] | 0;2911 -1 var bl3 = b3 & 0x1fff;2912 -1 var bh3 = b3 >>> 13;2913 -1 var b4 = b[4] | 0;2914 -1 var bl4 = b4 & 0x1fff;2915 -1 var bh4 = b4 >>> 13;2916 -1 var b5 = b[5] | 0;2917 -1 var bl5 = b5 & 0x1fff;2918 -1 var bh5 = b5 >>> 13;2919 -1 var b6 = b[6] | 0;2920 -1 var bl6 = b6 & 0x1fff;2921 -1 var bh6 = b6 >>> 13;2922 -1 var b7 = b[7] | 0;2923 -1 var bl7 = b7 & 0x1fff;2924 -1 var bh7 = b7 >>> 13;2925 -1 var b8 = b[8] | 0;2926 -1 var bl8 = b8 & 0x1fff;2927 -1 var bh8 = b8 >>> 13;2928 -1 var b9 = b[9] | 0;2929 -1 var bl9 = b9 & 0x1fff;2930 -1 var bh9 = b9 >>> 13;2931 -12932 -1 out.negative = self.negative ^ num.negative;2933 -1 out.length = 19;2934 -1 /* k = 0 */2935 -1 lo = Math.imul(al0, bl0);2936 -1 mid = Math.imul(al0, bh0);2937 -1 mid = (mid + Math.imul(ah0, bl0)) | 0;2938 -1 hi = Math.imul(ah0, bh0);2939 -1 var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;2940 -1 c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;2941 -1 w0 &= 0x3ffffff;2942 -1 /* k = 1 */2943 -1 lo = Math.imul(al1, bl0);2944 -1 mid = Math.imul(al1, bh0);2945 -1 mid = (mid + Math.imul(ah1, bl0)) | 0;2946 -1 hi = Math.imul(ah1, bh0);2947 -1 lo = (lo + Math.imul(al0, bl1)) | 0;2948 -1 mid = (mid + Math.imul(al0, bh1)) | 0;2949 -1 mid = (mid + Math.imul(ah0, bl1)) | 0;2950 -1 hi = (hi + Math.imul(ah0, bh1)) | 0;2951 -1 var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;2952 -1 c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;2953 -1 w1 &= 0x3ffffff;2954 -1 /* k = 2 */2955 -1 lo = Math.imul(al2, bl0);2956 -1 mid = Math.imul(al2, bh0);2957 -1 mid = (mid + Math.imul(ah2, bl0)) | 0;2958 -1 hi = Math.imul(ah2, bh0);2959 -1 lo = (lo + Math.imul(al1, bl1)) | 0;2960 -1 mid = (mid + Math.imul(al1, bh1)) | 0;2961 -1 mid = (mid + Math.imul(ah1, bl1)) | 0;2962 -1 hi = (hi + Math.imul(ah1, bh1)) | 0;2963 -1 lo = (lo + Math.imul(al0, bl2)) | 0;2964 -1 mid = (mid + Math.imul(al0, bh2)) | 0;2965 -1 mid = (mid + Math.imul(ah0, bl2)) | 0;2966 -1 hi = (hi + Math.imul(ah0, bh2)) | 0;2967 -1 var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;2968 -1 c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;2969 -1 w2 &= 0x3ffffff;2970 -1 /* k = 3 */2971 -1 lo = Math.imul(al3, bl0);2972 -1 mid = Math.imul(al3, bh0);2973 -1 mid = (mid + Math.imul(ah3, bl0)) | 0;2974 -1 hi = Math.imul(ah3, bh0);2975 -1 lo = (lo + Math.imul(al2, bl1)) | 0;2976 -1 mid = (mid + Math.imul(al2, bh1)) | 0;2977 -1 mid = (mid + Math.imul(ah2, bl1)) | 0;2978 -1 hi = (hi + Math.imul(ah2, bh1)) | 0;2979 -1 lo = (lo + Math.imul(al1, bl2)) | 0;2980 -1 mid = (mid + Math.imul(al1, bh2)) | 0;2981 -1 mid = (mid + Math.imul(ah1, bl2)) | 0;2982 -1 hi = (hi + Math.imul(ah1, bh2)) | 0;2983 -1 lo = (lo + Math.imul(al0, bl3)) | 0;2984 -1 mid = (mid + Math.imul(al0, bh3)) | 0;2985 -1 mid = (mid + Math.imul(ah0, bl3)) | 0;2986 -1 hi = (hi + Math.imul(ah0, bh3)) | 0;2987 -1 var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;2988 -1 c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;2989 -1 w3 &= 0x3ffffff;2990 -1 /* k = 4 */2991 -1 lo = Math.imul(al4, bl0);2992 -1 mid = Math.imul(al4, bh0);2993 -1 mid = (mid + Math.imul(ah4, bl0)) | 0;2994 -1 hi = Math.imul(ah4, bh0);2995 -1 lo = (lo + Math.imul(al3, bl1)) | 0;2996 -1 mid = (mid + Math.imul(al3, bh1)) | 0;2997 -1 mid = (mid + Math.imul(ah3, bl1)) | 0;2998 -1 hi = (hi + Math.imul(ah3, bh1)) | 0;2999 -1 lo = (lo + Math.imul(al2, bl2)) | 0;3000 -1 mid = (mid + Math.imul(al2, bh2)) | 0;3001 -1 mid = (mid + Math.imul(ah2, bl2)) | 0;3002 -1 hi = (hi + Math.imul(ah2, bh2)) | 0;3003 -1 lo = (lo + Math.imul(al1, bl3)) | 0;3004 -1 mid = (mid + Math.imul(al1, bh3)) | 0;3005 -1 mid = (mid + Math.imul(ah1, bl3)) | 0;3006 -1 hi = (hi + Math.imul(ah1, bh3)) | 0;3007 -1 lo = (lo + Math.imul(al0, bl4)) | 0;3008 -1 mid = (mid + Math.imul(al0, bh4)) | 0;3009 -1 mid = (mid + Math.imul(ah0, bl4)) | 0;3010 -1 hi = (hi + Math.imul(ah0, bh4)) | 0;3011 -1 var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3012 -1 c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;3013 -1 w4 &= 0x3ffffff;3014 -1 /* k = 5 */3015 -1 lo = Math.imul(al5, bl0);3016 -1 mid = Math.imul(al5, bh0);3017 -1 mid = (mid + Math.imul(ah5, bl0)) | 0;3018 -1 hi = Math.imul(ah5, bh0);3019 -1 lo = (lo + Math.imul(al4, bl1)) | 0;3020 -1 mid = (mid + Math.imul(al4, bh1)) | 0;3021 -1 mid = (mid + Math.imul(ah4, bl1)) | 0;3022 -1 hi = (hi + Math.imul(ah4, bh1)) | 0;3023 -1 lo = (lo + Math.imul(al3, bl2)) | 0;3024 -1 mid = (mid + Math.imul(al3, bh2)) | 0;3025 -1 mid = (mid + Math.imul(ah3, bl2)) | 0;3026 -1 hi = (hi + Math.imul(ah3, bh2)) | 0;3027 -1 lo = (lo + Math.imul(al2, bl3)) | 0;3028 -1 mid = (mid + Math.imul(al2, bh3)) | 0;3029 -1 mid = (mid + Math.imul(ah2, bl3)) | 0;3030 -1 hi = (hi + Math.imul(ah2, bh3)) | 0;3031 -1 lo = (lo + Math.imul(al1, bl4)) | 0;3032 -1 mid = (mid + Math.imul(al1, bh4)) | 0;3033 -1 mid = (mid + Math.imul(ah1, bl4)) | 0;3034 -1 hi = (hi + Math.imul(ah1, bh4)) | 0;3035 -1 lo = (lo + Math.imul(al0, bl5)) | 0;3036 -1 mid = (mid + Math.imul(al0, bh5)) | 0;3037 -1 mid = (mid + Math.imul(ah0, bl5)) | 0;3038 -1 hi = (hi + Math.imul(ah0, bh5)) | 0;3039 -1 var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3040 -1 c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;3041 -1 w5 &= 0x3ffffff;3042 -1 /* k = 6 */3043 -1 lo = Math.imul(al6, bl0);3044 -1 mid = Math.imul(al6, bh0);3045 -1 mid = (mid + Math.imul(ah6, bl0)) | 0;3046 -1 hi = Math.imul(ah6, bh0);3047 -1 lo = (lo + Math.imul(al5, bl1)) | 0;3048 -1 mid = (mid + Math.imul(al5, bh1)) | 0;3049 -1 mid = (mid + Math.imul(ah5, bl1)) | 0;3050 -1 hi = (hi + Math.imul(ah5, bh1)) | 0;3051 -1 lo = (lo + Math.imul(al4, bl2)) | 0;3052 -1 mid = (mid + Math.imul(al4, bh2)) | 0;3053 -1 mid = (mid + Math.imul(ah4, bl2)) | 0;3054 -1 hi = (hi + Math.imul(ah4, bh2)) | 0;3055 -1 lo = (lo + Math.imul(al3, bl3)) | 0;3056 -1 mid = (mid + Math.imul(al3, bh3)) | 0;3057 -1 mid = (mid + Math.imul(ah3, bl3)) | 0;3058 -1 hi = (hi + Math.imul(ah3, bh3)) | 0;3059 -1 lo = (lo + Math.imul(al2, bl4)) | 0;3060 -1 mid = (mid + Math.imul(al2, bh4)) | 0;3061 -1 mid = (mid + Math.imul(ah2, bl4)) | 0;3062 -1 hi = (hi + Math.imul(ah2, bh4)) | 0;3063 -1 lo = (lo + Math.imul(al1, bl5)) | 0;3064 -1 mid = (mid + Math.imul(al1, bh5)) | 0;3065 -1 mid = (mid + Math.imul(ah1, bl5)) | 0;3066 -1 hi = (hi + Math.imul(ah1, bh5)) | 0;3067 -1 lo = (lo + Math.imul(al0, bl6)) | 0;3068 -1 mid = (mid + Math.imul(al0, bh6)) | 0;3069 -1 mid = (mid + Math.imul(ah0, bl6)) | 0;3070 -1 hi = (hi + Math.imul(ah0, bh6)) | 0;3071 -1 var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3072 -1 c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;3073 -1 w6 &= 0x3ffffff;3074 -1 /* k = 7 */3075 -1 lo = Math.imul(al7, bl0);3076 -1 mid = Math.imul(al7, bh0);3077 -1 mid = (mid + Math.imul(ah7, bl0)) | 0;3078 -1 hi = Math.imul(ah7, bh0);3079 -1 lo = (lo + Math.imul(al6, bl1)) | 0;3080 -1 mid = (mid + Math.imul(al6, bh1)) | 0;3081 -1 mid = (mid + Math.imul(ah6, bl1)) | 0;3082 -1 hi = (hi + Math.imul(ah6, bh1)) | 0;3083 -1 lo = (lo + Math.imul(al5, bl2)) | 0;3084 -1 mid = (mid + Math.imul(al5, bh2)) | 0;3085 -1 mid = (mid + Math.imul(ah5, bl2)) | 0;3086 -1 hi = (hi + Math.imul(ah5, bh2)) | 0;3087 -1 lo = (lo + Math.imul(al4, bl3)) | 0;3088 -1 mid = (mid + Math.imul(al4, bh3)) | 0;3089 -1 mid = (mid + Math.imul(ah4, bl3)) | 0;3090 -1 hi = (hi + Math.imul(ah4, bh3)) | 0;3091 -1 lo = (lo + Math.imul(al3, bl4)) | 0;3092 -1 mid = (mid + Math.imul(al3, bh4)) | 0;3093 -1 mid = (mid + Math.imul(ah3, bl4)) | 0;3094 -1 hi = (hi + Math.imul(ah3, bh4)) | 0;3095 -1 lo = (lo + Math.imul(al2, bl5)) | 0;3096 -1 mid = (mid + Math.imul(al2, bh5)) | 0;3097 -1 mid = (mid + Math.imul(ah2, bl5)) | 0;3098 -1 hi = (hi + Math.imul(ah2, bh5)) | 0;3099 -1 lo = (lo + Math.imul(al1, bl6)) | 0;3100 -1 mid = (mid + Math.imul(al1, bh6)) | 0;3101 -1 mid = (mid + Math.imul(ah1, bl6)) | 0;3102 -1 hi = (hi + Math.imul(ah1, bh6)) | 0;3103 -1 lo = (lo + Math.imul(al0, bl7)) | 0;3104 -1 mid = (mid + Math.imul(al0, bh7)) | 0;3105 -1 mid = (mid + Math.imul(ah0, bl7)) | 0;3106 -1 hi = (hi + Math.imul(ah0, bh7)) | 0;3107 -1 var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3108 -1 c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;3109 -1 w7 &= 0x3ffffff;3110 -1 /* k = 8 */3111 -1 lo = Math.imul(al8, bl0);3112 -1 mid = Math.imul(al8, bh0);3113 -1 mid = (mid + Math.imul(ah8, bl0)) | 0;3114 -1 hi = Math.imul(ah8, bh0);3115 -1 lo = (lo + Math.imul(al7, bl1)) | 0;3116 -1 mid = (mid + Math.imul(al7, bh1)) | 0;3117 -1 mid = (mid + Math.imul(ah7, bl1)) | 0;3118 -1 hi = (hi + Math.imul(ah7, bh1)) | 0;3119 -1 lo = (lo + Math.imul(al6, bl2)) | 0;3120 -1 mid = (mid + Math.imul(al6, bh2)) | 0;3121 -1 mid = (mid + Math.imul(ah6, bl2)) | 0;3122 -1 hi = (hi + Math.imul(ah6, bh2)) | 0;3123 -1 lo = (lo + Math.imul(al5, bl3)) | 0;3124 -1 mid = (mid + Math.imul(al5, bh3)) | 0;3125 -1 mid = (mid + Math.imul(ah5, bl3)) | 0;3126 -1 hi = (hi + Math.imul(ah5, bh3)) | 0;3127 -1 lo = (lo + Math.imul(al4, bl4)) | 0;3128 -1 mid = (mid + Math.imul(al4, bh4)) | 0;3129 -1 mid = (mid + Math.imul(ah4, bl4)) | 0;3130 -1 hi = (hi + Math.imul(ah4, bh4)) | 0;3131 -1 lo = (lo + Math.imul(al3, bl5)) | 0;3132 -1 mid = (mid + Math.imul(al3, bh5)) | 0;3133 -1 mid = (mid + Math.imul(ah3, bl5)) | 0;3134 -1 hi = (hi + Math.imul(ah3, bh5)) | 0;3135 -1 lo = (lo + Math.imul(al2, bl6)) | 0;3136 -1 mid = (mid + Math.imul(al2, bh6)) | 0;3137 -1 mid = (mid + Math.imul(ah2, bl6)) | 0;3138 -1 hi = (hi + Math.imul(ah2, bh6)) | 0;3139 -1 lo = (lo + Math.imul(al1, bl7)) | 0;3140 -1 mid = (mid + Math.imul(al1, bh7)) | 0;3141 -1 mid = (mid + Math.imul(ah1, bl7)) | 0;3142 -1 hi = (hi + Math.imul(ah1, bh7)) | 0;3143 -1 lo = (lo + Math.imul(al0, bl8)) | 0;3144 -1 mid = (mid + Math.imul(al0, bh8)) | 0;3145 -1 mid = (mid + Math.imul(ah0, bl8)) | 0;3146 -1 hi = (hi + Math.imul(ah0, bh8)) | 0;3147 -1 var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3148 -1 c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;3149 -1 w8 &= 0x3ffffff;3150 -1 /* k = 9 */3151 -1 lo = Math.imul(al9, bl0);3152 -1 mid = Math.imul(al9, bh0);3153 -1 mid = (mid + Math.imul(ah9, bl0)) | 0;3154 -1 hi = Math.imul(ah9, bh0);3155 -1 lo = (lo + Math.imul(al8, bl1)) | 0;3156 -1 mid = (mid + Math.imul(al8, bh1)) | 0;3157 -1 mid = (mid + Math.imul(ah8, bl1)) | 0;3158 -1 hi = (hi + Math.imul(ah8, bh1)) | 0;3159 -1 lo = (lo + Math.imul(al7, bl2)) | 0;3160 -1 mid = (mid + Math.imul(al7, bh2)) | 0;3161 -1 mid = (mid + Math.imul(ah7, bl2)) | 0;3162 -1 hi = (hi + Math.imul(ah7, bh2)) | 0;3163 -1 lo = (lo + Math.imul(al6, bl3)) | 0;3164 -1 mid = (mid + Math.imul(al6, bh3)) | 0;3165 -1 mid = (mid + Math.imul(ah6, bl3)) | 0;3166 -1 hi = (hi + Math.imul(ah6, bh3)) | 0;3167 -1 lo = (lo + Math.imul(al5, bl4)) | 0;3168 -1 mid = (mid + Math.imul(al5, bh4)) | 0;3169 -1 mid = (mid + Math.imul(ah5, bl4)) | 0;3170 -1 hi = (hi + Math.imul(ah5, bh4)) | 0;3171 -1 lo = (lo + Math.imul(al4, bl5)) | 0;3172 -1 mid = (mid + Math.imul(al4, bh5)) | 0;3173 -1 mid = (mid + Math.imul(ah4, bl5)) | 0;3174 -1 hi = (hi + Math.imul(ah4, bh5)) | 0;3175 -1 lo = (lo + Math.imul(al3, bl6)) | 0;3176 -1 mid = (mid + Math.imul(al3, bh6)) | 0;3177 -1 mid = (mid + Math.imul(ah3, bl6)) | 0;3178 -1 hi = (hi + Math.imul(ah3, bh6)) | 0;3179 -1 lo = (lo + Math.imul(al2, bl7)) | 0;3180 -1 mid = (mid + Math.imul(al2, bh7)) | 0;3181 -1 mid = (mid + Math.imul(ah2, bl7)) | 0;3182 -1 hi = (hi + Math.imul(ah2, bh7)) | 0;3183 -1 lo = (lo + Math.imul(al1, bl8)) | 0;3184 -1 mid = (mid + Math.imul(al1, bh8)) | 0;3185 -1 mid = (mid + Math.imul(ah1, bl8)) | 0;3186 -1 hi = (hi + Math.imul(ah1, bh8)) | 0;3187 -1 lo = (lo + Math.imul(al0, bl9)) | 0;3188 -1 mid = (mid + Math.imul(al0, bh9)) | 0;3189 -1 mid = (mid + Math.imul(ah0, bl9)) | 0;3190 -1 hi = (hi + Math.imul(ah0, bh9)) | 0;3191 -1 var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3192 -1 c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;3193 -1 w9 &= 0x3ffffff;3194 -1 /* k = 10 */3195 -1 lo = Math.imul(al9, bl1);3196 -1 mid = Math.imul(al9, bh1);3197 -1 mid = (mid + Math.imul(ah9, bl1)) | 0;3198 -1 hi = Math.imul(ah9, bh1);3199 -1 lo = (lo + Math.imul(al8, bl2)) | 0;3200 -1 mid = (mid + Math.imul(al8, bh2)) | 0;3201 -1 mid = (mid + Math.imul(ah8, bl2)) | 0;3202 -1 hi = (hi + Math.imul(ah8, bh2)) | 0;3203 -1 lo = (lo + Math.imul(al7, bl3)) | 0;3204 -1 mid = (mid + Math.imul(al7, bh3)) | 0;3205 -1 mid = (mid + Math.imul(ah7, bl3)) | 0;3206 -1 hi = (hi + Math.imul(ah7, bh3)) | 0;3207 -1 lo = (lo + Math.imul(al6, bl4)) | 0;3208 -1 mid = (mid + Math.imul(al6, bh4)) | 0;3209 -1 mid = (mid + Math.imul(ah6, bl4)) | 0;3210 -1 hi = (hi + Math.imul(ah6, bh4)) | 0;3211 -1 lo = (lo + Math.imul(al5, bl5)) | 0;3212 -1 mid = (mid + Math.imul(al5, bh5)) | 0;3213 -1 mid = (mid + Math.imul(ah5, bl5)) | 0;3214 -1 hi = (hi + Math.imul(ah5, bh5)) | 0;3215 -1 lo = (lo + Math.imul(al4, bl6)) | 0;3216 -1 mid = (mid + Math.imul(al4, bh6)) | 0;3217 -1 mid = (mid + Math.imul(ah4, bl6)) | 0;3218 -1 hi = (hi + Math.imul(ah4, bh6)) | 0;3219 -1 lo = (lo + Math.imul(al3, bl7)) | 0;3220 -1 mid = (mid + Math.imul(al3, bh7)) | 0;3221 -1 mid = (mid + Math.imul(ah3, bl7)) | 0;3222 -1 hi = (hi + Math.imul(ah3, bh7)) | 0;3223 -1 lo = (lo + Math.imul(al2, bl8)) | 0;3224 -1 mid = (mid + Math.imul(al2, bh8)) | 0;3225 -1 mid = (mid + Math.imul(ah2, bl8)) | 0;3226 -1 hi = (hi + Math.imul(ah2, bh8)) | 0;3227 -1 lo = (lo + Math.imul(al1, bl9)) | 0;3228 -1 mid = (mid + Math.imul(al1, bh9)) | 0;3229 -1 mid = (mid + Math.imul(ah1, bl9)) | 0;3230 -1 hi = (hi + Math.imul(ah1, bh9)) | 0;3231 -1 var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3232 -1 c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;3233 -1 w10 &= 0x3ffffff;3234 -1 /* k = 11 */3235 -1 lo = Math.imul(al9, bl2);3236 -1 mid = Math.imul(al9, bh2);3237 -1 mid = (mid + Math.imul(ah9, bl2)) | 0;3238 -1 hi = Math.imul(ah9, bh2);3239 -1 lo = (lo + Math.imul(al8, bl3)) | 0;3240 -1 mid = (mid + Math.imul(al8, bh3)) | 0;3241 -1 mid = (mid + Math.imul(ah8, bl3)) | 0;3242 -1 hi = (hi + Math.imul(ah8, bh3)) | 0;3243 -1 lo = (lo + Math.imul(al7, bl4)) | 0;3244 -1 mid = (mid + Math.imul(al7, bh4)) | 0;3245 -1 mid = (mid + Math.imul(ah7, bl4)) | 0;3246 -1 hi = (hi + Math.imul(ah7, bh4)) | 0;3247 -1 lo = (lo + Math.imul(al6, bl5)) | 0;3248 -1 mid = (mid + Math.imul(al6, bh5)) | 0;3249 -1 mid = (mid + Math.imul(ah6, bl5)) | 0;3250 -1 hi = (hi + Math.imul(ah6, bh5)) | 0;3251 -1 lo = (lo + Math.imul(al5, bl6)) | 0;3252 -1 mid = (mid + Math.imul(al5, bh6)) | 0;3253 -1 mid = (mid + Math.imul(ah5, bl6)) | 0;3254 -1 hi = (hi + Math.imul(ah5, bh6)) | 0;3255 -1 lo = (lo + Math.imul(al4, bl7)) | 0;3256 -1 mid = (mid + Math.imul(al4, bh7)) | 0;3257 -1 mid = (mid + Math.imul(ah4, bl7)) | 0;3258 -1 hi = (hi + Math.imul(ah4, bh7)) | 0;3259 -1 lo = (lo + Math.imul(al3, bl8)) | 0;3260 -1 mid = (mid + Math.imul(al3, bh8)) | 0;3261 -1 mid = (mid + Math.imul(ah3, bl8)) | 0;3262 -1 hi = (hi + Math.imul(ah3, bh8)) | 0;3263 -1 lo = (lo + Math.imul(al2, bl9)) | 0;3264 -1 mid = (mid + Math.imul(al2, bh9)) | 0;3265 -1 mid = (mid + Math.imul(ah2, bl9)) | 0;3266 -1 hi = (hi + Math.imul(ah2, bh9)) | 0;3267 -1 var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3268 -1 c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;3269 -1 w11 &= 0x3ffffff;3270 -1 /* k = 12 */3271 -1 lo = Math.imul(al9, bl3);3272 -1 mid = Math.imul(al9, bh3);3273 -1 mid = (mid + Math.imul(ah9, bl3)) | 0;3274 -1 hi = Math.imul(ah9, bh3);3275 -1 lo = (lo + Math.imul(al8, bl4)) | 0;3276 -1 mid = (mid + Math.imul(al8, bh4)) | 0;3277 -1 mid = (mid + Math.imul(ah8, bl4)) | 0;3278 -1 hi = (hi + Math.imul(ah8, bh4)) | 0;3279 -1 lo = (lo + Math.imul(al7, bl5)) | 0;3280 -1 mid = (mid + Math.imul(al7, bh5)) | 0;3281 -1 mid = (mid + Math.imul(ah7, bl5)) | 0;3282 -1 hi = (hi + Math.imul(ah7, bh5)) | 0;3283 -1 lo = (lo + Math.imul(al6, bl6)) | 0;3284 -1 mid = (mid + Math.imul(al6, bh6)) | 0;3285 -1 mid = (mid + Math.imul(ah6, bl6)) | 0;3286 -1 hi = (hi + Math.imul(ah6, bh6)) | 0;3287 -1 lo = (lo + Math.imul(al5, bl7)) | 0;3288 -1 mid = (mid + Math.imul(al5, bh7)) | 0;3289 -1 mid = (mid + Math.imul(ah5, bl7)) | 0;3290 -1 hi = (hi + Math.imul(ah5, bh7)) | 0;3291 -1 lo = (lo + Math.imul(al4, bl8)) | 0;3292 -1 mid = (mid + Math.imul(al4, bh8)) | 0;3293 -1 mid = (mid + Math.imul(ah4, bl8)) | 0;3294 -1 hi = (hi + Math.imul(ah4, bh8)) | 0;3295 -1 lo = (lo + Math.imul(al3, bl9)) | 0;3296 -1 mid = (mid + Math.imul(al3, bh9)) | 0;3297 -1 mid = (mid + Math.imul(ah3, bl9)) | 0;3298 -1 hi = (hi + Math.imul(ah3, bh9)) | 0;3299 -1 var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3300 -1 c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;3301 -1 w12 &= 0x3ffffff;3302 -1 /* k = 13 */3303 -1 lo = Math.imul(al9, bl4);3304 -1 mid = Math.imul(al9, bh4);3305 -1 mid = (mid + Math.imul(ah9, bl4)) | 0;3306 -1 hi = Math.imul(ah9, bh4);3307 -1 lo = (lo + Math.imul(al8, bl5)) | 0;3308 -1 mid = (mid + Math.imul(al8, bh5)) | 0;3309 -1 mid = (mid + Math.imul(ah8, bl5)) | 0;3310 -1 hi = (hi + Math.imul(ah8, bh5)) | 0;3311 -1 lo = (lo + Math.imul(al7, bl6)) | 0;3312 -1 mid = (mid + Math.imul(al7, bh6)) | 0;3313 -1 mid = (mid + Math.imul(ah7, bl6)) | 0;3314 -1 hi = (hi + Math.imul(ah7, bh6)) | 0;3315 -1 lo = (lo + Math.imul(al6, bl7)) | 0;3316 -1 mid = (mid + Math.imul(al6, bh7)) | 0;3317 -1 mid = (mid + Math.imul(ah6, bl7)) | 0;3318 -1 hi = (hi + Math.imul(ah6, bh7)) | 0;3319 -1 lo = (lo + Math.imul(al5, bl8)) | 0;3320 -1 mid = (mid + Math.imul(al5, bh8)) | 0;3321 -1 mid = (mid + Math.imul(ah5, bl8)) | 0;3322 -1 hi = (hi + Math.imul(ah5, bh8)) | 0;3323 -1 lo = (lo + Math.imul(al4, bl9)) | 0;3324 -1 mid = (mid + Math.imul(al4, bh9)) | 0;3325 -1 mid = (mid + Math.imul(ah4, bl9)) | 0;3326 -1 hi = (hi + Math.imul(ah4, bh9)) | 0;3327 -1 var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3328 -1 c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;3329 -1 w13 &= 0x3ffffff;3330 -1 /* k = 14 */3331 -1 lo = Math.imul(al9, bl5);3332 -1 mid = Math.imul(al9, bh5);3333 -1 mid = (mid + Math.imul(ah9, bl5)) | 0;3334 -1 hi = Math.imul(ah9, bh5);3335 -1 lo = (lo + Math.imul(al8, bl6)) | 0;3336 -1 mid = (mid + Math.imul(al8, bh6)) | 0;3337 -1 mid = (mid + Math.imul(ah8, bl6)) | 0;3338 -1 hi = (hi + Math.imul(ah8, bh6)) | 0;3339 -1 lo = (lo + Math.imul(al7, bl7)) | 0;3340 -1 mid = (mid + Math.imul(al7, bh7)) | 0;3341 -1 mid = (mid + Math.imul(ah7, bl7)) | 0;3342 -1 hi = (hi + Math.imul(ah7, bh7)) | 0;3343 -1 lo = (lo + Math.imul(al6, bl8)) | 0;3344 -1 mid = (mid + Math.imul(al6, bh8)) | 0;3345 -1 mid = (mid + Math.imul(ah6, bl8)) | 0;3346 -1 hi = (hi + Math.imul(ah6, bh8)) | 0;3347 -1 lo = (lo + Math.imul(al5, bl9)) | 0;3348 -1 mid = (mid + Math.imul(al5, bh9)) | 0;3349 -1 mid = (mid + Math.imul(ah5, bl9)) | 0;3350 -1 hi = (hi + Math.imul(ah5, bh9)) | 0;3351 -1 var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3352 -1 c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;3353 -1 w14 &= 0x3ffffff;3354 -1 /* k = 15 */3355 -1 lo = Math.imul(al9, bl6);3356 -1 mid = Math.imul(al9, bh6);3357 -1 mid = (mid + Math.imul(ah9, bl6)) | 0;3358 -1 hi = Math.imul(ah9, bh6);3359 -1 lo = (lo + Math.imul(al8, bl7)) | 0;3360 -1 mid = (mid + Math.imul(al8, bh7)) | 0;3361 -1 mid = (mid + Math.imul(ah8, bl7)) | 0;3362 -1 hi = (hi + Math.imul(ah8, bh7)) | 0;3363 -1 lo = (lo + Math.imul(al7, bl8)) | 0;3364 -1 mid = (mid + Math.imul(al7, bh8)) | 0;3365 -1 mid = (mid + Math.imul(ah7, bl8)) | 0;3366 -1 hi = (hi + Math.imul(ah7, bh8)) | 0;3367 -1 lo = (lo + Math.imul(al6, bl9)) | 0;3368 -1 mid = (mid + Math.imul(al6, bh9)) | 0;3369 -1 mid = (mid + Math.imul(ah6, bl9)) | 0;3370 -1 hi = (hi + Math.imul(ah6, bh9)) | 0;3371 -1 var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3372 -1 c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;3373 -1 w15 &= 0x3ffffff;3374 -1 /* k = 16 */3375 -1 lo = Math.imul(al9, bl7);3376 -1 mid = Math.imul(al9, bh7);3377 -1 mid = (mid + Math.imul(ah9, bl7)) | 0;3378 -1 hi = Math.imul(ah9, bh7);3379 -1 lo = (lo + Math.imul(al8, bl8)) | 0;3380 -1 mid = (mid + Math.imul(al8, bh8)) | 0;3381 -1 mid = (mid + Math.imul(ah8, bl8)) | 0;3382 -1 hi = (hi + Math.imul(ah8, bh8)) | 0;3383 -1 lo = (lo + Math.imul(al7, bl9)) | 0;3384 -1 mid = (mid + Math.imul(al7, bh9)) | 0;3385 -1 mid = (mid + Math.imul(ah7, bl9)) | 0;3386 -1 hi = (hi + Math.imul(ah7, bh9)) | 0;3387 -1 var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3388 -1 c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;3389 -1 w16 &= 0x3ffffff;3390 -1 /* k = 17 */3391 -1 lo = Math.imul(al9, bl8);3392 -1 mid = Math.imul(al9, bh8);3393 -1 mid = (mid + Math.imul(ah9, bl8)) | 0;3394 -1 hi = Math.imul(ah9, bh8);3395 -1 lo = (lo + Math.imul(al8, bl9)) | 0;3396 -1 mid = (mid + Math.imul(al8, bh9)) | 0;3397 -1 mid = (mid + Math.imul(ah8, bl9)) | 0;3398 -1 hi = (hi + Math.imul(ah8, bh9)) | 0;3399 -1 var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3400 -1 c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;3401 -1 w17 &= 0x3ffffff;3402 -1 /* k = 18 */3403 -1 lo = Math.imul(al9, bl9);3404 -1 mid = Math.imul(al9, bh9);3405 -1 mid = (mid + Math.imul(ah9, bl9)) | 0;3406 -1 hi = Math.imul(ah9, bh9);3407 -1 var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;3408 -1 c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;3409 -1 w18 &= 0x3ffffff;3410 -1 o[0] = w0;3411 -1 o[1] = w1;3412 -1 o[2] = w2;3413 -1 o[3] = w3;3414 -1 o[4] = w4;3415 -1 o[5] = w5;3416 -1 o[6] = w6;3417 -1 o[7] = w7;3418 -1 o[8] = w8;3419 -1 o[9] = w9;3420 -1 o[10] = w10;3421 -1 o[11] = w11;3422 -1 o[12] = w12;3423 -1 o[13] = w13;3424 -1 o[14] = w14;3425 -1 o[15] = w15;3426 -1 o[16] = w16;3427 -1 o[17] = w17;3428 -1 o[18] = w18;3429 -1 if (c !== 0) {3430 -1 o[19] = c;3431 -1 out.length++;3432 -1 }3433 -1 return out;3434 -1 };3435 -13436 -1 // Polyfill comb3437 -1 if (!Math.imul) {3438 -1 comb10MulTo = smallMulTo;3439 -1 }3440 -13441 -1 function bigMulTo (self, num, out) {3442 -1 out.negative = num.negative ^ self.negative;3443 -1 out.length = self.length + num.length;3444 -13445 -1 var carry = 0;3446 -1 var hncarry = 0;3447 -1 for (var k = 0; k < out.length - 1; k++) {3448 -1 // Sum all words with the same `i + j = k` and accumulate `ncarry`,3449 -1 // note that ncarry could be >= 0x3ffffff3450 -1 var ncarry = hncarry;3451 -1 hncarry = 0;3452 -1 var rword = carry & 0x3ffffff;3453 -1 var maxJ = Math.min(k, num.length - 1);3454 -1 for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {3455 -1 var i = k - j;3456 -1 var a = self.words[i] | 0;3457 -1 var b = num.words[j] | 0;3458 -1 var r = a * b;3459 -13460 -1 var lo = r & 0x3ffffff;3461 -1 ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;3462 -1 lo = (lo + rword) | 0;3463 -1 rword = lo & 0x3ffffff;3464 -1 ncarry = (ncarry + (lo >>> 26)) | 0;3465 -13466 -1 hncarry += ncarry >>> 26;3467 -1 ncarry &= 0x3ffffff;3468 -1 }3469 -1 out.words[k] = rword;3470 -1 carry = ncarry;3471 -1 ncarry = hncarry;3472 -1 }3473 -1 if (carry !== 0) {3474 -1 out.words[k] = carry;-1 1777 /** -1 1778 * Compute a desired luminance given a given luminance and a desired contrast ratio. -1 1779 * @param {number} luminance The given luminance. -1 1780 * @param {number} contrast The desired contrast ratio. -1 1781 * @param {boolean} higher Whether the desired luminance is higher or lower than the given luminance. -1 1782 * @return {number} The desired luminance. -1 1783 */ -1 1784 axs.color.luminanceFromContrastRatio = function(luminance, contrast, higher) { -1 1785 if (higher) { -1 1786 var newLuminance = (luminance + 0.05) * contrast - 0.05; -1 1787 return newLuminance; 3475 1788 } else {3476 -1 out.length--;-1 1789 var newLuminance = (luminance + 0.05) / contrast - 0.05; -1 1790 return newLuminance; 3477 1791 } -1 1792 }; 3478 17933479 -1 return out.strip();3480 -1 }-1 1794 /** -1 1795 * Given a color in YCbCr format and a desired luminance, pick a new color with the desired luminance which is -1 1796 * as close as possible to the original color. -1 1797 * @param {axs.color.YCbCr} ycc The original color in YCbCr form. -1 1798 * @param {number} luma The desired luminance -1 1799 * @return {!axs.color.Color} A new color in RGB. -1 1800 */ -1 1801 axs.color.translateColor = function(ycc, luma) { -1 1802 var endpoint = (luma > ycc.luma) ? axs.color.WHITE_YCC : axs.color.BLACK_YCC; -1 1803 var cubeFaces = (endpoint == axs.color.WHITE_YCC) ? axs.color.YCC_CUBE_FACES_WHITE -1 1804 : axs.color.YCC_CUBE_FACES_BLACK; 3481 18053482 -1 function jumboMulTo (self, num, out) {3483 -1 var fftm = new FFTM();3484 -1 return fftm.mulp(self, num, out);3485 -1 }-1 1806 var a = new axs.color.YCbCr([0, ycc.Cb, ycc.Cr]); -1 1807 var b = new axs.color.YCbCr([1, ycc.Cb, ycc.Cr]); -1 1808 var line = { a: a, b: b }; 3486 18093487 -1 BN.prototype.mulTo = function mulTo (num, out) {3488 -1 var res;3489 -1 var len = this.length + num.length;3490 -1 if (this.length === 10 && num.length === 10) {3491 -1 res = comb10MulTo(this, num, out);3492 -1 } else if (len < 63) {3493 -1 res = smallMulTo(this, num, out);3494 -1 } else if (len < 1024) {3495 -1 res = bigMulTo(this, num, out);3496 -1 } else {3497 -1 res = jumboMulTo(this, num, out);-1 1810 var intersection = null; -1 1811 for (var i = 0; i < cubeFaces.length; i++) { -1 1812 var cubeFace = cubeFaces[i]; -1 1813 intersection = axs.color.findIntersection(line, cubeFace); -1 1814 // If intersection within [0, 1] in Z axis, it is within the cube. -1 1815 if (intersection.z >= 0 && intersection.z <= 1) -1 1816 break; 3498 1817 }3499 -13500 -1 return res;3501 -1 };3502 -13503 -1 // Cooley-Tukey algorithm for FFT3504 -1 // slightly revisited to rely on looping instead of recursion3505 -13506 -1 function FFTM (x, y) {3507 -1 this.x = x;3508 -1 this.y = y;3509 -1 }3510 -13511 -1 FFTM.prototype.makeRBT = function makeRBT (N) {3512 -1 var t = new Array(N);3513 -1 var l = BN.prototype._countBits(N) - 1;3514 -1 for (var i = 0; i < N; i++) {3515 -1 t[i] = this.revBin(i, l, N);-1 1818 if (!intersection) { -1 1819 // Should never happen -1 1820 throw "Couldn't find intersection with YCbCr color cube for Cb=" + ycc.Cb + ", Cr=" + ycc.Cr + "."; 3516 1821 }3517 -13518 -1 return t;3519 -1 };3520 -13521 -1 // Returns binary-reversed representation of `x`3522 -1 FFTM.prototype.revBin = function revBin (x, l, N) {3523 -1 if (x === 0 || x === N - 1) return x;3524 -13525 -1 var rb = 0;3526 -1 for (var i = 0; i < l; i++) {3527 -1 rb |= (x & 1) << (l - i - 1);3528 -1 x >>= 1;-1 1822 if (intersection.x != ycc.x || intersection.y != ycc.y) { -1 1823 // Should never happen -1 1824 throw "Intersection has wrong Cb/Cr values."; 3529 1825 } 3530 18263531 -1 return rb;3532 -1 };3533 -13534 -1 // Performs "tweedling" phase, therefore 'emulating'3535 -1 // behaviour of the recursive algorithm3536 -1 FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {3537 -1 for (var i = 0; i < N; i++) {3538 -1 rtws[i] = rws[rbt[i]];3539 -1 itws[i] = iws[rbt[i]];-1 1827 // If intersection.luma is closer to endpoint than desired luma, then luma is inside cube -1 1828 // and we can immediately return new value. -1 1829 if (Math.abs(endpoint.luma - intersection.luma) < Math.abs(endpoint.luma - luma)) { -1 1830 var translatedColor = [luma, ycc.Cb, ycc.Cr]; -1 1831 return axs.color.fromYCbCrArray(translatedColor); 3540 1832 }3541 -1 };3542 -13543 -1 FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {3544 -1 this.permute(rbt, rws, iws, rtws, itws, N);3545 -13546 -1 for (var s = 1; s < N; s <<= 1) {3547 -1 var l = s << 1;3548 -13549 -1 var rtwdf = Math.cos(2 * Math.PI / l);3550 -1 var itwdf = Math.sin(2 * Math.PI / l);3551 -13552 -1 for (var p = 0; p < N; p += l) {3553 -1 var rtwdf_ = rtwdf;3554 -1 var itwdf_ = itwdf;3555 18333556 -1 for (var j = 0; j < s; j++) {3557 -1 var re = rtws[p + j];3558 -1 var ie = itws[p + j];3559 -13560 -1 var ro = rtws[p + j + s];3561 -1 var io = itws[p + j + s];3562 -13563 -1 var rx = rtwdf_ * ro - itwdf_ * io;-1 1834 // Otherwise, translate from intersection towards white/black such that luma is correct. -1 1835 var dLuma = luma - intersection.luma; -1 1836 var scale = dLuma / (endpoint.luma - intersection.luma); -1 1837 var translatedColor = [ luma, -1 1838 intersection.Cb - (intersection.Cb * scale), -1 1839 intersection.Cr - (intersection.Cr * scale) ]; 3564 18403565 -1 io = rtwdf_ * io + itwdf_ * ro;3566 -1 ro = rx;-1 1841 return axs.color.fromYCbCrArray(translatedColor); -1 1842 }; 3567 18433568 -1 rtws[p + j] = re + ro;3569 -1 itws[p + j] = ie + io;-1 1844 /** @typedef {{fg: string, bg: string, contrast: string}} */ -1 1845 axs.color.SuggestedColors; 3570 18463571 -1 rtws[p + j + s] = re - ro;3572 -1 itws[p + j + s] = ie - io;-1 1847 /** -1 1848 * @param {axs.color.Color} bgColor -1 1849 * @param {axs.color.Color} fgColor -1 1850 * @param {Object.<string, number>} desiredContrastRatios A map of label to desired contrast ratio. -1 1851 * @return {Object.<string, axs.color.SuggestedColors>} -1 1852 */ -1 1853 axs.color.suggestColors = function(bgColor, fgColor, desiredContrastRatios) { -1 1854 var colors = {}; -1 1855 var bgLuminance = axs.color.calculateLuminance(bgColor); -1 1856 var fgLuminance = axs.color.calculateLuminance(fgColor); 3573 18573574 -1 /* jshint maxdepth : false */3575 -1 if (j !== l) {3576 -1 rx = rtwdf * rtwdf_ - itwdf * itwdf_;-1 1858 var fgLuminanceIsHigher = fgLuminance > bgLuminance; -1 1859 var fgYCbCr = axs.color.toYCbCr(fgColor); -1 1860 var bgYCbCr = axs.color.toYCbCr(bgColor); -1 1861 for (var desiredLabel in desiredContrastRatios) { -1 1862 var desiredContrast = desiredContrastRatios[desiredLabel]; 3577 18633578 -1 itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;3579 -1 rtwdf_ = rx;3580 -1 }-1 1864 var desiredFgLuminance = axs.color.luminanceFromContrastRatio(bgLuminance, desiredContrast + 0.02, fgLuminanceIsHigher); -1 1865 if (desiredFgLuminance <= 1 && desiredFgLuminance >= 0) { -1 1866 var newFgColor = axs.color.translateColor(fgYCbCr, desiredFgLuminance); -1 1867 var newContrastRatio = axs.color.calculateContrastRatio(newFgColor, bgColor); -1 1868 var suggestedColors = {}; -1 1869 suggestedColors.fg = /** @type {!string} */ (axs.color.colorToString(newFgColor)); -1 1870 suggestedColors.bg = /** @type {!string} */ (axs.color.colorToString(bgColor)); -1 1871 suggestedColors.contrast = /** @type {!string} */ (newContrastRatio.toFixed(2)); -1 1872 colors[desiredLabel] = /** @type {axs.color.SuggestedColors} */ (suggestedColors); -1 1873 continue; 3581 1874 }3582 -1 }3583 -1 }3584 -1 };3585 -13586 -1 FFTM.prototype.guessLen13b = function guessLen13b (n, m) {3587 -1 var N = Math.max(m, n) | 1;3588 -1 var odd = N & 1;3589 -1 var i = 0;3590 -1 for (N = N / 2 | 0; N; N = N >>> 1) {3591 -1 i++;3592 -1 }3593 -13594 -1 return 1 << i + 1 + odd;3595 -1 };3596 -13597 -1 FFTM.prototype.conjugate = function conjugate (rws, iws, N) {3598 -1 if (N <= 1) return;3599 -13600 -1 for (var i = 0; i < N / 2; i++) {3601 -1 var t = rws[i];3602 -13603 -1 rws[i] = rws[N - i - 1];3604 -1 rws[N - i - 1] = t;3605 -13606 -1 t = iws[i];3607 -13608 -1 iws[i] = -iws[N - i - 1];3609 -1 iws[N - i - 1] = -t;3610 -1 }3611 -1 };3612 -13613 -1 FFTM.prototype.normalize13b = function normalize13b (ws, N) {3614 -1 var carry = 0;3615 -1 for (var i = 0; i < N / 2; i++) {3616 -1 var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +3617 -1 Math.round(ws[2 * i] / N) +3618 -1 carry;3619 -13620 -1 ws[i] = w & 0x3ffffff;3621 -13622 -1 if (w < 0x4000000) {3623 -1 carry = 0;3624 -1 } else {3625 -1 carry = w / 0x4000000 | 0;3626 -1 }3627 -1 }3628 -13629 -1 return ws;3630 -1 };3631 -13632 -1 FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {3633 -1 var carry = 0;3634 -1 for (var i = 0; i < len; i++) {3635 -1 carry = carry + (ws[i] | 0);3636 -13637 -1 rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;3638 -1 rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;3639 -1 }3640 -13641 -1 // Pad with zeroes3642 -1 for (i = 2 * len; i < N; ++i) {3643 -1 rws[i] = 0;3644 -1 }3645 -13646 -1 assert(carry === 0);3647 -1 assert((carry & ~0x1fff) === 0);3648 -1 };3649 -13650 -1 FFTM.prototype.stub = function stub (N) {3651 -1 var ph = new Array(N);3652 -1 for (var i = 0; i < N; i++) {3653 -1 ph[i] = 0;3654 -1 }3655 -13656 -1 return ph;3657 -1 };3658 -13659 -1 FFTM.prototype.mulp = function mulp (x, y, out) {3660 -1 var N = 2 * this.guessLen13b(x.length, y.length);3661 -13662 -1 var rbt = this.makeRBT(N);3663 -13664 -1 var _ = this.stub(N);3665 -13666 -1 var rws = new Array(N);3667 -1 var rwst = new Array(N);3668 -1 var iwst = new Array(N);3669 -13670 -1 var nrws = new Array(N);3671 -1 var nrwst = new Array(N);3672 -1 var niwst = new Array(N);3673 -13674 -1 var rmws = out.words;3675 -1 rmws.length = N;3676 -13677 -1 this.convert13b(x.words, x.length, rws, N);3678 -1 this.convert13b(y.words, y.length, nrws, N);3679 -13680 -1 this.transform(rws, _, rwst, iwst, N, rbt);3681 -1 this.transform(nrws, _, nrwst, niwst, N, rbt);3682 -13683 -1 for (var i = 0; i < N; i++) {3684 -1 var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];3685 -1 iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];3686 -1 rwst[i] = rx;3687 -1 }3688 -13689 -1 this.conjugate(rwst, iwst, N);3690 -1 this.transform(rwst, iwst, rmws, _, N, rbt);3691 -1 this.conjugate(rmws, _, N);3692 -1 this.normalize13b(rmws, N);3693 -13694 -1 out.negative = x.negative ^ y.negative;3695 -1 out.length = x.length + y.length;3696 -1 return out.strip();3697 -1 };3698 -13699 -1 // Multiply `this` by `num`3700 -1 BN.prototype.mul = function mul (num) {3701 -1 var out = new BN(null);3702 -1 out.words = new Array(this.length + num.length);3703 -1 return this.mulTo(num, out);3704 -1 };3705 -13706 -1 // Multiply employing FFT3707 -1 BN.prototype.mulf = function mulf (num) {3708 -1 var out = new BN(null);3709 -1 out.words = new Array(this.length + num.length);3710 -1 return jumboMulTo(this, num, out);3711 -1 };3712 18753713 -1 // In-place Multiplication3714 -1 BN.prototype.imul = function imul (num) {3715 -1 return this.clone().mulTo(num, this);3716 -1 };3717 -13718 -1 BN.prototype.imuln = function imuln (num) {3719 -1 assert(typeof num === 'number');3720 -1 assert(num < 0x4000000);3721 -13722 -1 // Carry3723 -1 var carry = 0;3724 -1 for (var i = 0; i < this.length; i++) {3725 -1 var w = (this.words[i] | 0) * num;3726 -1 var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);3727 -1 carry >>= 26;3728 -1 carry += (w / 0x4000000) | 0;3729 -1 // NOTE: lo is 27bit maximum3730 -1 carry += lo >>> 26;3731 -1 this.words[i] = lo & 0x3ffffff;3732 -1 }3733 -13734 -1 if (carry !== 0) {3735 -1 this.words[i] = carry;3736 -1 this.length++;3737 -1 }3738 -13739 -1 return this;3740 -1 };3741 -13742 -1 BN.prototype.muln = function muln (num) {3743 -1 return this.clone().imuln(num);3744 -1 };3745 -13746 -1 // `this` * `this`3747 -1 BN.prototype.sqr = function sqr () {3748 -1 return this.mul(this);3749 -1 };3750 -13751 -1 // `this` * `this` in-place3752 -1 BN.prototype.isqr = function isqr () {3753 -1 return this.imul(this.clone());3754 -1 };3755 -13756 -1 // Math.pow(`this`, `num`)3757 -1 BN.prototype.pow = function pow (num) {3758 -1 var w = toBitArray(num);3759 -1 if (w.length === 0) return new BN(1);3760 -13761 -1 // Skip leading zeroes3762 -1 var res = this;3763 -1 for (var i = 0; i < w.length; i++, res = res.sqr()) {3764 -1 if (w[i] !== 0) break;3765 -1 }3766 -13767 -1 if (++i < w.length) {3768 -1 for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {3769 -1 if (w[i] === 0) continue;3770 -13771 -1 res = res.mul(q);3772 -1 }3773 -1 }3774 -13775 -1 return res;3776 -1 };3777 -13778 -1 // Shift-left in-place3779 -1 BN.prototype.iushln = function iushln (bits) {3780 -1 assert(typeof bits === 'number' && bits >= 0);3781 -1 var r = bits % 26;3782 -1 var s = (bits - r) / 26;3783 -1 var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);3784 -1 var i;3785 -13786 -1 if (r !== 0) {3787 -1 var carry = 0;3788 -13789 -1 for (i = 0; i < this.length; i++) {3790 -1 var newCarry = this.words[i] & carryMask;3791 -1 var c = ((this.words[i] | 0) - newCarry) << r;3792 -1 this.words[i] = c | carry;3793 -1 carry = newCarry >>> (26 - r);3794 -1 }3795 -13796 -1 if (carry) {3797 -1 this.words[i] = carry;3798 -1 this.length++;3799 -1 }3800 -1 }3801 -13802 -1 if (s !== 0) {3803 -1 for (i = this.length - 1; i >= 0; i--) {3804 -1 this.words[i + s] = this.words[i];3805 -1 }3806 -13807 -1 for (i = 0; i < s; i++) {3808 -1 this.words[i] = 0;3809 -1 }3810 -13811 -1 this.length += s;3812 -1 }3813 -13814 -1 return this.strip();3815 -1 };3816 -13817 -1 BN.prototype.ishln = function ishln (bits) {3818 -1 // TODO(indutny): implement me3819 -1 assert(this.negative === 0);3820 -1 return this.iushln(bits);3821 -1 };3822 -13823 -1 // Shift-right in-place3824 -1 // NOTE: `hint` is a lowest bit before trailing zeroes3825 -1 // NOTE: if `extended` is present - it will be filled with destroyed bits3826 -1 BN.prototype.iushrn = function iushrn (bits, hint, extended) {3827 -1 assert(typeof bits === 'number' && bits >= 0);3828 -1 var h;3829 -1 if (hint) {3830 -1 h = (hint - (hint % 26)) / 26;3831 -1 } else {3832 -1 h = 0;3833 -1 }3834 -13835 -1 var r = bits % 26;3836 -1 var s = Math.min((bits - r) / 26, this.length);3837 -1 var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);3838 -1 var maskedWords = extended;3839 -13840 -1 h -= s;3841 -1 h = Math.max(0, h);3842 -13843 -1 // Extended mode, copy masked part3844 -1 if (maskedWords) {3845 -1 for (var i = 0; i < s; i++) {3846 -1 maskedWords.words[i] = this.words[i];3847 -1 }3848 -1 maskedWords.length = s;3849 -1 }3850 -13851 -1 if (s === 0) {3852 -1 // No-op, we should not move anything at all3853 -1 } else if (this.length > s) {3854 -1 this.length -= s;3855 -1 for (i = 0; i < this.length; i++) {3856 -1 this.words[i] = this.words[i + s];3857 -1 }3858 -1 } else {3859 -1 this.words[0] = 0;3860 -1 this.length = 1;3861 -1 }3862 -13863 -1 var carry = 0;3864 -1 for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {3865 -1 var word = this.words[i] | 0;3866 -1 this.words[i] = (carry << (26 - r)) | (word >>> r);3867 -1 carry = word & mask;-1 1876 var desiredBgLuminance = axs.color.luminanceFromContrastRatio(fgLuminance, desiredContrast + 0.02, !fgLuminanceIsHigher); -1 1877 if (desiredBgLuminance <= 1 && desiredBgLuminance >= 0) { -1 1878 var newBgColor = axs.color.translateColor(bgYCbCr, desiredBgLuminance); -1 1879 var newContrastRatio = axs.color.calculateContrastRatio(fgColor, newBgColor); -1 1880 var suggestedColors = {}; -1 1881 suggestedColors.bg = /** @type {!string} */ (axs.color.colorToString(newBgColor)); -1 1882 suggestedColors.fg = /** @type {!string} */ (axs.color.colorToString(fgColor)); -1 1883 suggestedColors.contrast = /** @type {!string} */ (newContrastRatio.toFixed(2)); -1 1884 colors[desiredLabel] = /** @type {axs.color.SuggestedColors} */ (suggestedColors); -1 1885 } 3868 1886 } -1 1887 return colors; -1 1888 }; 3869 18893870 -1 // Push carried bits as a mask3871 -1 if (maskedWords && carry !== 0) {3872 -1 maskedWords.words[maskedWords.length++] = carry;3873 -1 }-1 1890 /** -1 1891 * Combine the two given color according to alpha blending. -1 1892 * @param {axs.color.Color} fgColor -1 1893 * @param {axs.color.Color} bgColor -1 1894 * @return {axs.color.Color} -1 1895 */ -1 1896 axs.color.flattenColors = function(fgColor, bgColor) { -1 1897 var alpha = fgColor.alpha; -1 1898 var r = ((1 - alpha) * bgColor.red) + (alpha * fgColor.red); -1 1899 var g = ((1 - alpha) * bgColor.green) + (alpha * fgColor.green); -1 1900 var b = ((1 - alpha) * bgColor.blue) + (alpha * fgColor.blue); -1 1901 var a = fgColor.alpha + (bgColor.alpha * (1 - fgColor.alpha)); 3874 19023875 -1 if (this.length === 0) {3876 -1 this.words[0] = 0;3877 -1 this.length = 1;3878 -1 }-1 1903 return new axs.color.Color(r, g, b, a); -1 1904 }; 3879 19053880 -1 return this.strip();3881 -1 };-1 1906 /** -1 1907 * Multiply the given vector by the given matrix. -1 1908 * @param {Array.<Array.<number>>} matrix A 3x3 matrix -1 1909 * @param {Array.<number>} vector A 3-element vector -1 1910 * @return {Array.<number>} A 3-element vector -1 1911 */ -1 1912 axs.color.multiplyMatrixVector = function(matrix, vector) { -1 1913 var a = matrix[0][0]; -1 1914 var b = matrix[0][1]; -1 1915 var c = matrix[0][2]; -1 1916 var d = matrix[1][0]; -1 1917 var e = matrix[1][1]; -1 1918 var f = matrix[1][2]; -1 1919 var g = matrix[2][0]; -1 1920 var h = matrix[2][1]; -1 1921 var k = matrix[2][2]; 3882 19223883 -1 BN.prototype.ishrn = function ishrn (bits, hint, extended) {3884 -1 // TODO(indutny): implement me3885 -1 assert(this.negative === 0);3886 -1 return this.iushrn(bits, hint, extended);3887 -1 };-1 1923 var x = vector[0]; -1 1924 var y = vector[1]; -1 1925 var z = vector[2]; 3888 19263889 -1 // Shift-left3890 -1 BN.prototype.shln = function shln (bits) {3891 -1 return this.clone().ishln(bits);3892 -1 };-1 1927 return [ -1 1928 a*x + b*y + c*z, -1 1929 d*x + e*y + f*z, -1 1930 g*x + h*y + k*z -1 1931 ]; -1 1932 }; 3893 19333894 -1 BN.prototype.ushln = function ushln (bits) {3895 -1 return this.clone().iushln(bits);3896 -1 };-1 1934 /** -1 1935 * Convert a given RGB color to YCbCr. -1 1936 * @param {axs.color.Color} color -1 1937 * @return {axs.color.YCbCr} -1 1938 */ -1 1939 axs.color.toYCbCr = function(color) { -1 1940 var rSRGB = color.red / 255; -1 1941 var gSRGB = color.green / 255; -1 1942 var bSRGB = color.blue / 255; 3897 19433898 -1 // Shift-right3899 -1 BN.prototype.shrn = function shrn (bits) {3900 -1 return this.clone().ishrn(bits);3901 -1 };-1 1944 var r = rSRGB <= 0.03928 ? rSRGB / 12.92 : Math.pow(((rSRGB + 0.055)/1.055), 2.4); -1 1945 var g = gSRGB <= 0.03928 ? gSRGB / 12.92 : Math.pow(((gSRGB + 0.055)/1.055), 2.4); -1 1946 var b = bSRGB <= 0.03928 ? bSRGB / 12.92 : Math.pow(((bSRGB + 0.055)/1.055), 2.4); 3902 19473903 -1 BN.prototype.ushrn = function ushrn (bits) {3904 -1 return this.clone().iushrn(bits);3905 -1 };-1 1948 return new axs.color.YCbCr(axs.color.multiplyMatrixVector(axs.color.YCC_MATRIX, [r, g, b])); -1 1949 }; 3906 19503907 -1 // Test if n bit is set3908 -1 BN.prototype.testn = function testn (bit) {3909 -1 assert(typeof bit === 'number' && bit >= 0);3910 -1 var r = bit % 26;3911 -1 var s = (bit - r) / 26;3912 -1 var q = 1 << r;-1 1951 /** -1 1952 * @param {axs.color.YCbCr} ycc -1 1953 * @return {!axs.color.Color} -1 1954 */ -1 1955 axs.color.fromYCbCr = function(ycc) { -1 1956 return axs.color.fromYCbCrArray([ycc.luma, ycc.Cb, ycc.Cr]); -1 1957 }; 3913 19583914 -1 // Fast case: bit is much higher than all existing words3915 -1 if (this.length <= s) return false;-1 1959 /** -1 1960 * Convert a color from a YCbCr color (as a vector) to an RGB color -1 1961 * @param {Array.<number>} yccArray -1 1962 * @return {!axs.color.Color} -1 1963 */ -1 1964 axs.color.fromYCbCrArray = function(yccArray) { -1 1965 var rgb = axs.color.multiplyMatrixVector(axs.color.INVERTED_YCC_MATRIX, yccArray); 3916 19663917 -1 // Check bit and return3918 -1 var w = this.words[s];-1 1967 var r = rgb[0]; -1 1968 var g = rgb[1]; -1 1969 var b = rgb[2]; -1 1970 var rSRGB = r <= 0.00303949 ? (r * 12.92) : (Math.pow(r, (1/2.4)) * 1.055) - 0.055; -1 1971 var gSRGB = g <= 0.00303949 ? (g * 12.92) : (Math.pow(g, (1/2.4)) * 1.055) - 0.055; -1 1972 var bSRGB = b <= 0.00303949 ? (b * 12.92) : (Math.pow(b, (1/2.4)) * 1.055) - 0.055; 3919 19733920 -1 return !!(w & q);3921 -1 };-1 1974 var red = Math.min(Math.max(Math.round(rSRGB * 255), 0), 255); -1 1975 var green = Math.min(Math.max(Math.round(gSRGB * 255), 0), 255); -1 1976 var blue = Math.min(Math.max(Math.round(bSRGB * 255), 0), 255); 3922 19773923 -1 // Return only lowers bits of number (in-place)3924 -1 BN.prototype.imaskn = function imaskn (bits) {3925 -1 assert(typeof bits === 'number' && bits >= 0);3926 -1 var r = bits % 26;3927 -1 var s = (bits - r) / 26;-1 1978 return new axs.color.Color(red, green, blue, 1); -1 1979 }; 3928 19803929 -1 assert(this.negative === 0, 'imaskn works only with positive numbers');-1 1981 /** -1 1982 * Returns an RGB to YCbCr conversion matrix for the given kR, kB constants. -1 1983 * @param {number} kR -1 1984 * @param {number} kB -1 1985 * @return {Array.<Array.<number>>} -1 1986 */ -1 1987 axs.color.RGBToYCbCrMatrix = function(kR, kB) { -1 1988 return [ -1 1989 [ -1 1990 kR, -1 1991 (1 - kR - kB), -1 1992 kB -1 1993 ], -1 1994 [ -1 1995 -kR/(2 - 2*kB), -1 1996 (kR + kB - 1)/(2 - 2*kB), -1 1997 (1 - kB)/(2 - 2*kB) -1 1998 ], -1 1999 [ -1 2000 (1 - kR)/(2 - 2*kR), -1 2001 (kR + kB - 1)/(2 - 2*kR), -1 2002 -kB/(2 - 2*kR) -1 2003 ] -1 2004 ]; -1 2005 }; 3930 20063931 -1 if (this.length <= s) {3932 -1 return this;3933 -1 }-1 2007 /** -1 2008 * Return the inverse of the given 3x3 matrix. -1 2009 * @param {Array.<Array.<number>>} matrix -1 2010 * @return Array.<Array.<number>> The inverse of the given matrix. -1 2011 */ -1 2012 axs.color.invert3x3Matrix = function(matrix) { -1 2013 var a = matrix[0][0]; -1 2014 var b = matrix[0][1]; -1 2015 var c = matrix[0][2]; -1 2016 var d = matrix[1][0]; -1 2017 var e = matrix[1][1]; -1 2018 var f = matrix[1][2]; -1 2019 var g = matrix[2][0]; -1 2020 var h = matrix[2][1]; -1 2021 var k = matrix[2][2]; 3934 20223935 -1 if (r !== 0) {3936 -1 s++;3937 -1 }3938 -1 this.length = Math.min(s, this.length);-1 2023 var A = (e*k - f*h); -1 2024 var B = (f*g - d*k); -1 2025 var C = (d*h - e*g); -1 2026 var D = (c*h - b*k); -1 2027 var E = (a*k - c*g); -1 2028 var F = (g*b - a*h); -1 2029 var G = (b*f - c*e); -1 2030 var H = (c*d - a*f); -1 2031 var K = (a*e - b*d); 3939 20323940 -1 if (r !== 0) {3941 -1 var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);3942 -1 this.words[this.length - 1] &= mask;3943 -1 }-1 2033 var det = a * (e*k - f*h) - b * (k*d - f*g) + c * (d*h - e*g); -1 2034 var z = 1/det; 3944 20353945 -1 return this.strip();3946 -1 };-1 2036 return axs.color.scalarMultiplyMatrix([ -1 2037 [ A, D, G ], -1 2038 [ B, E, H ], -1 2039 [ C, F, K ] -1 2040 ], z); -1 2041 }; 3947 20423948 -1 // Return only lowers bits of number3949 -1 BN.prototype.maskn = function maskn (bits) {3950 -1 return this.clone().imaskn(bits);3951 -1 };-1 2043 /** @typedef {{ a: axs.color.YCbCr, b: axs.color.YCbCr }} */ -1 2044 axs.color.Line; 3952 20453953 -1 // Add plain number `num` to `this`3954 -1 BN.prototype.iaddn = function iaddn (num) {3955 -1 assert(typeof num === 'number');3956 -1 assert(num < 0x4000000);3957 -1 if (num < 0) return this.isubn(-num);3958 -13959 -1 // Possible sign change3960 -1 if (this.negative !== 0) {3961 -1 if (this.length === 1 && (this.words[0] | 0) < num) {3962 -1 this.words[0] = num - (this.words[0] | 0);3963 -1 this.negative = 0;3964 -1 return this;3965 -1 }-1 2046 /** @typedef {{ p0: axs.color.YCbCr, p1: axs.color.YCbCr, p2: axs.color.YCbCr }} */ -1 2047 axs.color.Plane; 3966 20483967 -1 this.negative = 0;3968 -1 this.isubn(num);3969 -1 this.negative = 1;3970 -1 return this;3971 -1 }-1 2049 /** -1 2050 * Find the intersection between a line and a plane using -1 2051 * http://en.wikipedia.org/wiki/Line%E2%80%93plane_intersection#Parametric_form -1 2052 * @param {axs.color.Line} l -1 2053 * @param {axs.color.Plane} p -1 2054 * @return {axs.color.YCbCr} -1 2055 */ -1 2056 axs.color.findIntersection = function(l, p) { -1 2057 var lhs = [ l.a.x - p.p0.x, l.a.y - p.p0.y, l.a.z - p.p0.z ]; 3972 20583973 -1 // Add without checks3974 -1 return this._iaddn(num);3975 -1 };-1 2059 var matrix = [ [ l.a.x - l.b.x, p.p1.x - p.p0.x, p.p2.x - p.p0.x ], -1 2060 [ l.a.y - l.b.y, p.p1.y - p.p0.y, p.p2.y - p.p0.y ], -1 2061 [ l.a.z - l.b.z, p.p1.z - p.p0.z, p.p2.z - p.p0.z ] ]; -1 2062 var invertedMatrix = axs.color.invert3x3Matrix(matrix); 3976 20633977 -1 BN.prototype._iaddn = function _iaddn (num) {3978 -1 this.words[0] += num;-1 2064 var tuv = axs.color.multiplyMatrixVector(invertedMatrix, lhs); -1 2065 var t = tuv[0]; 3979 20663980 -1 // Carry3981 -1 for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {3982 -1 this.words[i] -= 0x4000000;3983 -1 if (i === this.length - 1) {3984 -1 this.words[i + 1] = 1;3985 -1 } else {3986 -1 this.words[i + 1]++;3987 -1 }3988 -1 }3989 -1 this.length = Math.max(this.length, i + 1);-1 2067 var result = l.a.add(l.b.subtract(l.a).multiply(t)); -1 2068 return result; -1 2069 }; 3990 20703991 -1 return this;3992 -1 };-1 2071 /** -1 2072 * Multiply a matrix by a scalar. -1 2073 * @param {Array.<Array.<number>>} matrix A 3x3 matrix. -1 2074 * @param {number} scalar -1 2075 * @return {Array.<Array.<number>>} -1 2076 */ -1 2077 axs.color.scalarMultiplyMatrix = function(matrix, scalar) { -1 2078 var result = []; 3993 20793994 -1 // Subtract plain number `num` from `this`3995 -1 BN.prototype.isubn = function isubn (num) {3996 -1 assert(typeof num === 'number');3997 -1 assert(num < 0x4000000);3998 -1 if (num < 0) return this.iaddn(-num);-1 2080 for (var i = 0; i < 3; i++) -1 2081 result[i] = axs.color.scalarMultiplyVector(matrix[i], scalar); 3999 20824000 -1 if (this.negative !== 0) {4001 -1 this.negative = 0;4002 -1 this.iaddn(num);4003 -1 this.negative = 1;4004 -1 return this;4005 -1 }-1 2083 return result; -1 2084 }; 4006 20854007 -1 this.words[0] -= num;-1 2086 /** -1 2087 * Multiply a vector by a scalar. -1 2088 * @param {Array.<number>} vector -1 2089 * @param {number} scalar -1 2090 * @return {Array.<number>} vector -1 2091 */ -1 2092 axs.color.scalarMultiplyVector = function(vector, scalar) { -1 2093 var result = []; -1 2094 for (var i = 0; i < vector.length; i++) -1 2095 result[i] = vector[i] * scalar; -1 2096 return result; -1 2097 }; 4008 20984009 -1 if (this.length === 1 && this.words[0] < 0) {4010 -1 this.words[0] = -this.words[0];4011 -1 this.negative = 1;4012 -1 } else {4013 -1 // Carry4014 -1 for (var i = 0; i < this.length && this.words[i] < 0; i++) {4015 -1 this.words[i] += 0x4000000;4016 -1 this.words[i + 1] -= 1;4017 -1 }4018 -1 }-1 2099 axs.color.kR = 0.2126; -1 2100 axs.color.kB = 0.0722; -1 2101 axs.color.YCC_MATRIX = axs.color.RGBToYCbCrMatrix(axs.color.kR, axs.color.kB); -1 2102 axs.color.INVERTED_YCC_MATRIX = axs.color.invert3x3Matrix(axs.color.YCC_MATRIX); 4019 21034020 -1 return this.strip();4021 -1 };-1 2104 axs.color.BLACK = new axs.color.Color(0, 0, 0, 1.0); -1 2105 axs.color.BLACK_YCC = axs.color.toYCbCr(axs.color.BLACK); -1 2106 axs.color.WHITE = new axs.color.Color(255, 255, 255, 1.0); -1 2107 axs.color.WHITE_YCC = axs.color.toYCbCr(axs.color.WHITE); -1 2108 axs.color.RED = new axs.color.Color(255, 0, 0, 1.0); -1 2109 axs.color.RED_YCC = axs.color.toYCbCr(axs.color.RED); -1 2110 axs.color.GREEN = new axs.color.Color(0, 255, 0, 1.0); -1 2111 axs.color.GREEN_YCC = axs.color.toYCbCr(axs.color.GREEN); -1 2112 axs.color.BLUE = new axs.color.Color(0, 0, 255, 1.0); -1 2113 axs.color.BLUE_YCC = axs.color.toYCbCr(axs.color.BLUE); -1 2114 axs.color.CYAN = new axs.color.Color(0, 255, 255, 1.0); -1 2115 axs.color.CYAN_YCC = axs.color.toYCbCr(axs.color.CYAN); -1 2116 axs.color.MAGENTA = new axs.color.Color(255, 0, 255, 1.0); -1 2117 axs.color.MAGENTA_YCC = axs.color.toYCbCr(axs.color.MAGENTA); -1 2118 axs.color.YELLOW = new axs.color.Color(255, 255, 0, 1.0); -1 2119 axs.color.YELLOW_YCC = axs.color.toYCbCr(axs.color.YELLOW); 4022 21204023 -1 BN.prototype.addn = function addn (num) {4024 -1 return this.clone().iaddn(num);4025 -1 };-1 2121 axs.color.YCC_CUBE_FACES_BLACK = [ { p0: axs.color.BLACK_YCC, p1: axs.color.RED_YCC, p2: axs.color.GREEN_YCC }, -1 2122 { p0: axs.color.BLACK_YCC, p1: axs.color.GREEN_YCC, p2: axs.color.BLUE_YCC }, -1 2123 { p0: axs.color.BLACK_YCC, p1: axs.color.BLUE_YCC, p2: axs.color.RED_YCC } ]; -1 2124 axs.color.YCC_CUBE_FACES_WHITE = [ { p0: axs.color.WHITE_YCC, p1: axs.color.CYAN_YCC, p2: axs.color.MAGENTA_YCC }, -1 2125 { p0: axs.color.WHITE_YCC, p1: axs.color.MAGENTA_YCC, p2: axs.color.YELLOW_YCC }, -1 2126 { p0: axs.color.WHITE_YCC, p1: axs.color.YELLOW_YCC, p2: axs.color.CYAN_YCC } ]; 4026 21274027 -1 BN.prototype.subn = function subn (num) {4028 -1 return this.clone().isubn(num);4029 -1 };-1 2128 },{}],6:[function(require,module,exports){ -1 2129 // Copyright 2012 Google Inc. -1 2130 // -1 2131 // Licensed under the Apache License, Version 2.0 (the "License"); -1 2132 // you may not use this file except in compliance with the License. -1 2133 // You may obtain a copy of the License at -1 2134 // -1 2135 // http://www.apache.org/licenses/LICENSE-2.0 -1 2136 // -1 2137 // Unless required by applicable law or agreed to in writing, software -1 2138 // distributed under the License is distributed on an "AS IS" BASIS, -1 2139 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -1 2140 // See the License for the specific language governing permissions and -1 2141 // limitations under the License. 4030 21424031 -1 BN.prototype.iabs = function iabs () {4032 -1 this.negative = 0;4033 -14034 -1 return this;4035 -1 };4036 -14037 -1 BN.prototype.abs = function abs () {4038 -1 return this.clone().iabs();4039 -1 };4040 -14041 -1 BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {4042 -1 var len = num.length + shift;4043 -1 var i;4044 -14045 -1 this._expand(len);4046 -14047 -1 var w;4048 -1 var carry = 0;4049 -1 for (i = 0; i < num.length; i++) {4050 -1 w = (this.words[i + shift] | 0) + carry;4051 -1 var right = (num.words[i] | 0) * mul;4052 -1 w -= right & 0x3ffffff;4053 -1 carry = (w >> 26) - ((right / 0x4000000) | 0);4054 -1 this.words[i + shift] = w & 0x3ffffff;4055 -1 }4056 -1 for (; i < this.length - shift; i++) {4057 -1 w = (this.words[i + shift] | 0) + carry;4058 -1 carry = w >> 26;4059 -1 this.words[i + shift] = w & 0x3ffffff;4060 -1 }4061 -14062 -1 if (carry === 0) return this.strip();4063 -14064 -1 // Subtraction overflow4065 -1 assert(carry === -1);4066 -1 carry = 0;4067 -1 for (i = 0; i < this.length; i++) {4068 -1 w = -(this.words[i] | 0) + carry;4069 -1 carry = w >> 26;4070 -1 this.words[i] = w & 0x3ffffff;4071 -1 }4072 -1 this.negative = 1;4073 -14074 -1 return this.strip();4075 -1 };4076 -14077 -1 BN.prototype._wordDiv = function _wordDiv (num, mode) {4078 -1 var shift = this.length - num.length;4079 -14080 -1 var a = this.clone();4081 -1 var b = num;4082 -14083 -1 // Normalize4084 -1 var bhi = b.words[b.length - 1] | 0;4085 -1 var bhiBits = this._countBits(bhi);4086 -1 shift = 26 - bhiBits;4087 -1 if (shift !== 0) {4088 -1 b = b.ushln(shift);4089 -1 a.iushln(shift);4090 -1 bhi = b.words[b.length - 1] | 0;4091 -1 }4092 -14093 -1 // Initialize quotient4094 -1 var m = a.length - b.length;4095 -1 var q;4096 -14097 -1 if (mode !== 'mod') {4098 -1 q = new BN(null);4099 -1 q.length = m + 1;4100 -1 q.words = new Array(q.length);4101 -1 for (var i = 0; i < q.length; i++) {4102 -1 q.words[i] = 0;4103 -1 }4104 -1 }4105 -14106 -1 var diff = a.clone()._ishlnsubmul(b, 1, m);4107 -1 if (diff.negative === 0) {4108 -1 a = diff;4109 -1 if (q) {4110 -1 q.words[m] = 1;4111 -1 }4112 -1 }4113 -14114 -1 for (var j = m - 1; j >= 0; j--) {4115 -1 var qj = (a.words[b.length + j] | 0) * 0x4000000 +4116 -1 (a.words[b.length + j - 1] | 0);4117 -14118 -1 // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max4119 -1 // (0x7ffffff)4120 -1 qj = Math.min((qj / bhi) | 0, 0x3ffffff);4121 -14122 -1 a._ishlnsubmul(b, qj, j);4123 -1 while (a.negative !== 0) {4124 -1 qj--;4125 -1 a.negative = 0;4126 -1 a._ishlnsubmul(b, 1, j);4127 -1 if (!a.isZero()) {4128 -1 a.negative ^= 1;4129 -1 }4130 -1 }4131 -1 if (q) {4132 -1 q.words[j] = qj;4133 -1 }4134 -1 }4135 -1 if (q) {4136 -1 q.strip();4137 -1 }4138 -1 a.strip();4139 -14140 -1 // Denormalize4141 -1 if (mode !== 'div' && shift !== 0) {4142 -1 a.iushrn(shift);4143 -1 }4144 -14145 -1 return {4146 -1 div: q || null,4147 -1 mod: a4148 -1 };4149 -1 };4150 -14151 -1 // NOTE: 1) `mode` can be set to `mod` to request mod only,4152 -1 // to `div` to request div only, or be absent to4153 -1 // request both div & mod4154 -1 // 2) `positive` is true if unsigned mod is requested4155 -1 BN.prototype.divmod = function divmod (num, mode, positive) {4156 -1 assert(!num.isZero());4157 -14158 -1 if (this.isZero()) {4159 -1 return {4160 -1 div: new BN(0),4161 -1 mod: new BN(0)4162 -1 };4163 -1 }4164 -14165 -1 var div, mod, res;4166 -1 if (this.negative !== 0 && num.negative === 0) {4167 -1 res = this.neg().divmod(num, mode);4168 -14169 -1 if (mode !== 'mod') {4170 -1 div = res.div.neg();4171 -1 }4172 -14173 -1 if (mode !== 'div') {4174 -1 mod = res.mod.neg();4175 -1 if (positive && mod.negative !== 0) {4176 -1 mod.iadd(num);4177 -1 }4178 -1 }4179 -14180 -1 return {4181 -1 div: div,4182 -1 mod: mod4183 -1 };4184 -1 }4185 -14186 -1 if (this.negative === 0 && num.negative !== 0) {4187 -1 res = this.divmod(num.neg(), mode);4188 -14189 -1 if (mode !== 'mod') {4190 -1 div = res.div.neg();4191 -1 }4192 -14193 -1 return {4194 -1 div: div,4195 -1 mod: res.mod4196 -1 };4197 -1 }4198 -14199 -1 if ((this.negative & num.negative) !== 0) {4200 -1 res = this.neg().divmod(num.neg(), mode);4201 -14202 -1 if (mode !== 'div') {4203 -1 mod = res.mod.neg();4204 -1 if (positive && mod.negative !== 0) {4205 -1 mod.isub(num);4206 -1 }4207 -1 }4208 -14209 -1 return {4210 -1 div: res.div,4211 -1 mod: mod4212 -1 };4213 -1 }4214 -14215 -1 // Both numbers are positive at this point4216 -14217 -1 // Strip both numbers to approximate shift value4218 -1 if (num.length > this.length || this.cmp(num) < 0) {4219 -1 return {4220 -1 div: new BN(0),4221 -1 mod: this4222 -1 };4223 -1 }4224 -14225 -1 // Very short reduction4226 -1 if (num.length === 1) {4227 -1 if (mode === 'div') {4228 -1 return {4229 -1 div: this.divn(num.words[0]),4230 -1 mod: null4231 -1 };4232 -1 }4233 -14234 -1 if (mode === 'mod') {4235 -1 return {4236 -1 div: null,4237 -1 mod: new BN(this.modn(num.words[0]))4238 -1 };4239 -1 }4240 -14241 -1 return {4242 -1 div: this.divn(num.words[0]),4243 -1 mod: new BN(this.modn(num.words[0]))4244 -1 };4245 -1 }4246 -14247 -1 return this._wordDiv(num, mode);4248 -1 };4249 -14250 -1 // Find `this` / `num`4251 -1 BN.prototype.div = function div (num) {4252 -1 return this.divmod(num, 'div', false).div;4253 -1 };4254 -14255 -1 // Find `this` % `num`4256 -1 BN.prototype.mod = function mod (num) {4257 -1 return this.divmod(num, 'mod', false).mod;4258 -1 };4259 -14260 -1 BN.prototype.umod = function umod (num) {4261 -1 return this.divmod(num, 'mod', true).mod;4262 -1 };4263 -14264 -1 // Find Round(`this` / `num`)4265 -1 BN.prototype.divRound = function divRound (num) {4266 -1 var dm = this.divmod(num);4267 -14268 -1 // Fast case - exact division4269 -1 if (dm.mod.isZero()) return dm.div;4270 -14271 -1 var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;4272 -14273 -1 var half = num.ushrn(1);4274 -1 var r2 = num.andln(1);4275 -1 var cmp = mod.cmp(half);4276 -14277 -1 // Round down4278 -1 if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;4279 -14280 -1 // Round up4281 -1 return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);4282 -1 };4283 -14284 -1 BN.prototype.modn = function modn (num) {4285 -1 assert(num <= 0x3ffffff);4286 -1 var p = (1 << 26) % num;4287 -14288 -1 var acc = 0;4289 -1 for (var i = this.length - 1; i >= 0; i--) {4290 -1 acc = (p * acc + (this.words[i] | 0)) % num;4291 -1 }4292 -14293 -1 return acc;4294 -1 };4295 -14296 -1 // In-place division by number4297 -1 BN.prototype.idivn = function idivn (num) {4298 -1 assert(num <= 0x3ffffff);4299 -14300 -1 var carry = 0;4301 -1 for (var i = this.length - 1; i >= 0; i--) {4302 -1 var w = (this.words[i] | 0) + carry * 0x4000000;4303 -1 this.words[i] = (w / num) | 0;4304 -1 carry = w % num;4305 -1 }4306 -14307 -1 return this.strip();4308 -1 };4309 -14310 -1 BN.prototype.divn = function divn (num) {4311 -1 return this.clone().idivn(num);4312 -1 };4313 -14314 -1 BN.prototype.egcd = function egcd (p) {4315 -1 assert(p.negative === 0);4316 -1 assert(!p.isZero());4317 -14318 -1 var x = this;4319 -1 var y = p.clone();4320 -14321 -1 if (x.negative !== 0) {4322 -1 x = x.umod(p);4323 -1 } else {4324 -1 x = x.clone();4325 -1 }4326 -14327 -1 // A * x + B * y = x4328 -1 var A = new BN(1);4329 -1 var B = new BN(0);4330 -14331 -1 // C * x + D * y = y4332 -1 var C = new BN(0);4333 -1 var D = new BN(1);4334 -14335 -1 var g = 0;4336 -14337 -1 while (x.isEven() && y.isEven()) {4338 -1 x.iushrn(1);4339 -1 y.iushrn(1);4340 -1 ++g;4341 -1 }4342 -14343 -1 var yp = y.clone();4344 -1 var xp = x.clone();4345 -14346 -1 while (!x.isZero()) {4347 -1 for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);4348 -1 if (i > 0) {4349 -1 x.iushrn(i);4350 -1 while (i-- > 0) {4351 -1 if (A.isOdd() || B.isOdd()) {4352 -1 A.iadd(yp);4353 -1 B.isub(xp);4354 -1 }4355 -14356 -1 A.iushrn(1);4357 -1 B.iushrn(1);4358 -1 }4359 -1 }4360 -14361 -1 for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);4362 -1 if (j > 0) {4363 -1 y.iushrn(j);4364 -1 while (j-- > 0) {4365 -1 if (C.isOdd() || D.isOdd()) {4366 -1 C.iadd(yp);4367 -1 D.isub(xp);4368 -1 }4369 -14370 -1 C.iushrn(1);4371 -1 D.iushrn(1);4372 -1 }4373 -1 }4374 -14375 -1 if (x.cmp(y) >= 0) {4376 -1 x.isub(y);4377 -1 A.isub(C);4378 -1 B.isub(D);4379 -1 } else {4380 -1 y.isub(x);4381 -1 C.isub(A);4382 -1 D.isub(B);4383 -1 }4384 -1 }4385 -14386 -1 return {4387 -1 a: C,4388 -1 b: D,4389 -1 gcd: y.iushln(g)4390 -1 };4391 -1 };4392 -14393 -1 // This is reduced incarnation of the binary EEA4394 -1 // above, designated to invert members of the4395 -1 // _prime_ fields F(p) at a maximal speed4396 -1 BN.prototype._invmp = function _invmp (p) {4397 -1 assert(p.negative === 0);4398 -1 assert(!p.isZero());4399 -14400 -1 var a = this;4401 -1 var b = p.clone();4402 -14403 -1 if (a.negative !== 0) {4404 -1 a = a.umod(p);4405 -1 } else {4406 -1 a = a.clone();4407 -1 }4408 -14409 -1 var x1 = new BN(1);4410 -1 var x2 = new BN(0);4411 -14412 -1 var delta = b.clone();4413 -14414 -1 while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {4415 -1 for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);4416 -1 if (i > 0) {4417 -1 a.iushrn(i);4418 -1 while (i-- > 0) {4419 -1 if (x1.isOdd()) {4420 -1 x1.iadd(delta);4421 -1 }4422 -14423 -1 x1.iushrn(1);4424 -1 }4425 -1 }4426 -14427 -1 for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);4428 -1 if (j > 0) {4429 -1 b.iushrn(j);4430 -1 while (j-- > 0) {4431 -1 if (x2.isOdd()) {4432 -1 x2.iadd(delta);4433 -1 }4434 -14435 -1 x2.iushrn(1);4436 -1 }4437 -1 }4438 -14439 -1 if (a.cmp(b) >= 0) {4440 -1 a.isub(b);4441 -1 x1.isub(x2);4442 -1 } else {4443 -1 b.isub(a);4444 -1 x2.isub(x1);4445 -1 }4446 -1 }4447 -14448 -1 var res;4449 -1 if (a.cmpn(1) === 0) {4450 -1 res = x1;4451 -1 } else {4452 -1 res = x2;4453 -1 }4454 -14455 -1 if (res.cmpn(0) < 0) {4456 -1 res.iadd(p);4457 -1 }4458 -14459 -1 return res;4460 -1 };4461 -14462 -1 BN.prototype.gcd = function gcd (num) {4463 -1 if (this.isZero()) return num.abs();4464 -1 if (num.isZero()) return this.abs();4465 -14466 -1 var a = this.clone();4467 -1 var b = num.clone();4468 -1 a.negative = 0;4469 -1 b.negative = 0;4470 -14471 -1 // Remove common factor of two4472 -1 for (var shift = 0; a.isEven() && b.isEven(); shift++) {4473 -1 a.iushrn(1);4474 -1 b.iushrn(1);4475 -1 }4476 -14477 -1 do {4478 -1 while (a.isEven()) {4479 -1 a.iushrn(1);4480 -1 }4481 -1 while (b.isEven()) {4482 -1 b.iushrn(1);4483 -1 }4484 -14485 -1 var r = a.cmp(b);4486 -1 if (r < 0) {4487 -1 // Swap `a` and `b` to make `a` always bigger than `b`4488 -1 var t = a;4489 -1 a = b;4490 -1 b = t;4491 -1 } else if (r === 0 || b.cmpn(1) === 0) {4492 -1 break;4493 -1 }4494 -14495 -1 a.isub(b);4496 -1 } while (true);4497 -14498 -1 return b.iushln(shift);4499 -1 };4500 -14501 -1 // Invert number in the field F(num)4502 -1 BN.prototype.invm = function invm (num) {4503 -1 return this.egcd(num).a.umod(num);4504 -1 };4505 -14506 -1 BN.prototype.isEven = function isEven () {4507 -1 return (this.words[0] & 1) === 0;4508 -1 };4509 -14510 -1 BN.prototype.isOdd = function isOdd () {4511 -1 return (this.words[0] & 1) === 1;4512 -1 };4513 -14514 -1 // And first word and num4515 -1 BN.prototype.andln = function andln (num) {4516 -1 return this.words[0] & num;4517 -1 };4518 -14519 -1 // Increment at the bit position in-line4520 -1 BN.prototype.bincn = function bincn (bit) {4521 -1 assert(typeof bit === 'number');4522 -1 var r = bit % 26;4523 -1 var s = (bit - r) / 26;4524 -1 var q = 1 << r;4525 -14526 -1 // Fast case: bit is much higher than all existing words4527 -1 if (this.length <= s) {4528 -1 this._expand(s + 1);4529 -1 this.words[s] |= q;4530 -1 return this;4531 -1 }4532 -14533 -1 // Add bit and propagate, if needed4534 -1 var carry = q;4535 -1 for (var i = s; carry !== 0 && i < this.length; i++) {4536 -1 var w = this.words[i] | 0;4537 -1 w += carry;4538 -1 carry = w >>> 26;4539 -1 w &= 0x3ffffff;4540 -1 this.words[i] = w;4541 -1 }4542 -1 if (carry !== 0) {4543 -1 this.words[i] = carry;4544 -1 this.length++;4545 -1 }4546 -1 return this;4547 -1 };4548 -14549 -1 BN.prototype.isZero = function isZero () {4550 -1 return this.length === 1 && this.words[0] === 0;4551 -1 };4552 -14553 -1 BN.prototype.cmpn = function cmpn (num) {4554 -1 var negative = num < 0;4555 -14556 -1 if (this.negative !== 0 && !negative) return -1;4557 -1 if (this.negative === 0 && negative) return 1;4558 -14559 -1 this.strip();4560 -14561 -1 var res;4562 -1 if (this.length > 1) {4563 -1 res = 1;4564 -1 } else {4565 -1 if (negative) {4566 -1 num = -num;4567 -1 }4568 -14569 -1 assert(num <= 0x3ffffff, 'Number is too big');4570 -14571 -1 var w = this.words[0] | 0;4572 -1 res = w === num ? 0 : w < num ? -1 : 1;4573 -1 }4574 -1 if (this.negative !== 0) return -res | 0;4575 -1 return res;4576 -1 };4577 -14578 -1 // Compare two numbers and return:4579 -1 // 1 - if `this` > `num`4580 -1 // 0 - if `this` == `num`4581 -1 // -1 - if `this` < `num`4582 -1 BN.prototype.cmp = function cmp (num) {4583 -1 if (this.negative !== 0 && num.negative === 0) return -1;4584 -1 if (this.negative === 0 && num.negative !== 0) return 1;4585 -14586 -1 var res = this.ucmp(num);4587 -1 if (this.negative !== 0) return -res | 0;4588 -1 return res;4589 -1 };4590 -14591 -1 // Unsigned comparison4592 -1 BN.prototype.ucmp = function ucmp (num) {4593 -1 // At this point both numbers have the same sign4594 -1 if (this.length > num.length) return 1;4595 -1 if (this.length < num.length) return -1;4596 -14597 -1 var res = 0;4598 -1 for (var i = this.length - 1; i >= 0; i--) {4599 -1 var a = this.words[i] | 0;4600 -1 var b = num.words[i] | 0;4601 -14602 -1 if (a === b) continue;4603 -1 if (a < b) {4604 -1 res = -1;4605 -1 } else if (a > b) {4606 -1 res = 1;4607 -1 }4608 -1 break;4609 -1 }4610 -1 return res;4611 -1 };4612 -14613 -1 BN.prototype.gtn = function gtn (num) {4614 -1 return this.cmpn(num) === 1;4615 -1 };4616 -14617 -1 BN.prototype.gt = function gt (num) {4618 -1 return this.cmp(num) === 1;4619 -1 };4620 -14621 -1 BN.prototype.gten = function gten (num) {4622 -1 return this.cmpn(num) >= 0;4623 -1 };4624 -14625 -1 BN.prototype.gte = function gte (num) {4626 -1 return this.cmp(num) >= 0;4627 -1 };4628 -14629 -1 BN.prototype.ltn = function ltn (num) {4630 -1 return this.cmpn(num) === -1;4631 -1 };4632 -14633 -1 BN.prototype.lt = function lt (num) {4634 -1 return this.cmp(num) === -1;4635 -1 };4636 -14637 -1 BN.prototype.lten = function lten (num) {4638 -1 return this.cmpn(num) <= 0;4639 -1 };4640 -14641 -1 BN.prototype.lte = function lte (num) {4642 -1 return this.cmp(num) <= 0;4643 -1 };4644 -14645 -1 BN.prototype.eqn = function eqn (num) {4646 -1 return this.cmpn(num) === 0;4647 -1 };4648 -14649 -1 BN.prototype.eq = function eq (num) {4650 -1 return this.cmp(num) === 0;4651 -1 };4652 -14653 -1 //4654 -1 // A reduce context, could be using montgomery or something better, depending4655 -1 // on the `m` itself.4656 -1 //4657 -1 BN.red = function red (num) {4658 -1 return new Red(num);4659 -1 };4660 -14661 -1 BN.prototype.toRed = function toRed (ctx) {4662 -1 assert(!this.red, 'Already a number in reduction context');4663 -1 assert(this.negative === 0, 'red works only with positives');4664 -1 return ctx.convertTo(this)._forceRed(ctx);4665 -1 };4666 -14667 -1 BN.prototype.fromRed = function fromRed () {4668 -1 assert(this.red, 'fromRed works only with numbers in reduction context');4669 -1 return this.red.convertFrom(this);4670 -1 };4671 -14672 -1 BN.prototype._forceRed = function _forceRed (ctx) {4673 -1 this.red = ctx;4674 -1 return this;4675 -1 };4676 -14677 -1 BN.prototype.forceRed = function forceRed (ctx) {4678 -1 assert(!this.red, 'Already a number in reduction context');4679 -1 return this._forceRed(ctx);4680 -1 };4681 -14682 -1 BN.prototype.redAdd = function redAdd (num) {4683 -1 assert(this.red, 'redAdd works only with red numbers');4684 -1 return this.red.add(this, num);4685 -1 };4686 -14687 -1 BN.prototype.redIAdd = function redIAdd (num) {4688 -1 assert(this.red, 'redIAdd works only with red numbers');4689 -1 return this.red.iadd(this, num);4690 -1 };4691 -14692 -1 BN.prototype.redSub = function redSub (num) {4693 -1 assert(this.red, 'redSub works only with red numbers');4694 -1 return this.red.sub(this, num);4695 -1 };4696 -14697 -1 BN.prototype.redISub = function redISub (num) {4698 -1 assert(this.red, 'redISub works only with red numbers');4699 -1 return this.red.isub(this, num);4700 -1 };4701 -14702 -1 BN.prototype.redShl = function redShl (num) {4703 -1 assert(this.red, 'redShl works only with red numbers');4704 -1 return this.red.shl(this, num);4705 -1 };4706 -14707 -1 BN.prototype.redMul = function redMul (num) {4708 -1 assert(this.red, 'redMul works only with red numbers');4709 -1 this.red._verify2(this, num);4710 -1 return this.red.mul(this, num);4711 -1 };4712 -14713 -1 BN.prototype.redIMul = function redIMul (num) {4714 -1 assert(this.red, 'redMul works only with red numbers');4715 -1 this.red._verify2(this, num);4716 -1 return this.red.imul(this, num);4717 -1 };4718 -14719 -1 BN.prototype.redSqr = function redSqr () {4720 -1 assert(this.red, 'redSqr works only with red numbers');4721 -1 this.red._verify1(this);4722 -1 return this.red.sqr(this);4723 -1 };4724 -14725 -1 BN.prototype.redISqr = function redISqr () {4726 -1 assert(this.red, 'redISqr works only with red numbers');4727 -1 this.red._verify1(this);4728 -1 return this.red.isqr(this);4729 -1 };4730 -14731 -1 // Square root over p4732 -1 BN.prototype.redSqrt = function redSqrt () {4733 -1 assert(this.red, 'redSqrt works only with red numbers');4734 -1 this.red._verify1(this);4735 -1 return this.red.sqrt(this);4736 -1 };4737 -14738 -1 BN.prototype.redInvm = function redInvm () {4739 -1 assert(this.red, 'redInvm works only with red numbers');4740 -1 this.red._verify1(this);4741 -1 return this.red.invm(this);4742 -1 };4743 -14744 -1 // Return negative clone of `this` % `red modulo`4745 -1 BN.prototype.redNeg = function redNeg () {4746 -1 assert(this.red, 'redNeg works only with red numbers');4747 -1 this.red._verify1(this);4748 -1 return this.red.neg(this);4749 -1 };4750 -14751 -1 BN.prototype.redPow = function redPow (num) {4752 -1 assert(this.red && !num.red, 'redPow(normalNum)');4753 -1 this.red._verify1(this);4754 -1 return this.red.pow(this, num);4755 -1 };4756 -14757 -1 // Prime numbers with efficient reduction4758 -1 var primes = {4759 -1 k256: null,4760 -1 p224: null,4761 -1 p192: null,4762 -1 p25519: null4763 -1 };4764 -14765 -1 // Pseudo-Mersenne prime4766 -1 function MPrime (name, p) {4767 -1 // P = 2 ^ N - K4768 -1 this.name = name;4769 -1 this.p = new BN(p, 16);4770 -1 this.n = this.p.bitLength();4771 -1 this.k = new BN(1).iushln(this.n).isub(this.p);4772 -14773 -1 this.tmp = this._tmp();4774 -1 }4775 -14776 -1 MPrime.prototype._tmp = function _tmp () {4777 -1 var tmp = new BN(null);4778 -1 tmp.words = new Array(Math.ceil(this.n / 13));4779 -1 return tmp;4780 -1 };4781 -14782 -1 MPrime.prototype.ireduce = function ireduce (num) {4783 -1 // Assumes that `num` is less than `P^2`4784 -1 // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)4785 -1 var r = num;4786 -1 var rlen;4787 -14788 -1 do {4789 -1 this.split(r, this.tmp);4790 -1 r = this.imulK(r);4791 -1 r = r.iadd(this.tmp);4792 -1 rlen = r.bitLength();4793 -1 } while (rlen > this.n);4794 -14795 -1 var cmp = rlen < this.n ? -1 : r.ucmp(this.p);4796 -1 if (cmp === 0) {4797 -1 r.words[0] = 0;4798 -1 r.length = 1;4799 -1 } else if (cmp > 0) {4800 -1 r.isub(this.p);4801 -1 } else {4802 -1 if (r.strip !== undefined) {4803 -1 // r is BN v4 instance4804 -1 r.strip();4805 -1 } else {4806 -1 // r is BN v5 instance4807 -1 r._strip();4808 -1 }4809 -1 }4810 -14811 -1 return r;4812 -1 };4813 -14814 -1 MPrime.prototype.split = function split (input, out) {4815 -1 input.iushrn(this.n, 0, out);4816 -1 };4817 -14818 -1 MPrime.prototype.imulK = function imulK (num) {4819 -1 return num.imul(this.k);4820 -1 };4821 -14822 -1 function K256 () {4823 -1 MPrime.call(4824 -1 this,4825 -1 'k256',4826 -1 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');4827 -1 }4828 -1 inherits(K256, MPrime);4829 -14830 -1 K256.prototype.split = function split (input, output) {4831 -1 // 256 = 9 * 26 + 224832 -1 var mask = 0x3fffff;4833 -14834 -1 var outLen = Math.min(input.length, 9);4835 -1 for (var i = 0; i < outLen; i++) {4836 -1 output.words[i] = input.words[i];4837 -1 }4838 -1 output.length = outLen;4839 -14840 -1 if (input.length <= 9) {4841 -1 input.words[0] = 0;4842 -1 input.length = 1;4843 -1 return;4844 -1 }4845 -14846 -1 // Shift by 9 limbs4847 -1 var prev = input.words[9];4848 -1 output.words[output.length++] = prev & mask;4849 -14850 -1 for (i = 10; i < input.length; i++) {4851 -1 var next = input.words[i] | 0;4852 -1 input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);4853 -1 prev = next;4854 -1 }4855 -1 prev >>>= 22;4856 -1 input.words[i - 10] = prev;4857 -1 if (prev === 0 && input.length > 10) {4858 -1 input.length -= 10;4859 -1 } else {4860 -1 input.length -= 9;4861 -1 }4862 -1 };4863 -14864 -1 K256.prototype.imulK = function imulK (num) {4865 -1 // K = 0x1000003d1 = [ 0x40, 0x3d1 ]4866 -1 num.words[num.length] = 0;4867 -1 num.words[num.length + 1] = 0;4868 -1 num.length += 2;4869 -14870 -1 // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x1000003904871 -1 var lo = 0;4872 -1 for (var i = 0; i < num.length; i++) {4873 -1 var w = num.words[i] | 0;4874 -1 lo += w * 0x3d1;4875 -1 num.words[i] = lo & 0x3ffffff;4876 -1 lo = w * 0x40 + ((lo / 0x4000000) | 0);4877 -1 }4878 -14879 -1 // Fast length reduction4880 -1 if (num.words[num.length - 1] === 0) {4881 -1 num.length--;4882 -1 if (num.words[num.length - 1] === 0) {4883 -1 num.length--;4884 -1 }4885 -1 }4886 -1 return num;4887 -1 };4888 -14889 -1 function P224 () {4890 -1 MPrime.call(4891 -1 this,4892 -1 'p224',4893 -1 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');4894 -1 }4895 -1 inherits(P224, MPrime);4896 -14897 -1 function P192 () {4898 -1 MPrime.call(4899 -1 this,4900 -1 'p192',4901 -1 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');4902 -1 }4903 -1 inherits(P192, MPrime);4904 -14905 -1 function P25519 () {4906 -1 // 2 ^ 255 - 194907 -1 MPrime.call(4908 -1 this,4909 -1 '25519',4910 -1 '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');4911 -1 }4912 -1 inherits(P25519, MPrime);4913 -14914 -1 P25519.prototype.imulK = function imulK (num) {4915 -1 // K = 0x134916 -1 var carry = 0;4917 -1 for (var i = 0; i < num.length; i++) {4918 -1 var hi = (num.words[i] | 0) * 0x13 + carry;4919 -1 var lo = hi & 0x3ffffff;4920 -1 hi >>>= 26;4921 -14922 -1 num.words[i] = lo;4923 -1 carry = hi;4924 -1 }4925 -1 if (carry !== 0) {4926 -1 num.words[num.length++] = carry;4927 -1 }4928 -1 return num;4929 -1 };4930 -14931 -1 // Exported mostly for testing purposes, use plain name instead4932 -1 BN._prime = function prime (name) {4933 -1 // Cached version of prime4934 -1 if (primes[name]) return primes[name];4935 -14936 -1 var prime;4937 -1 if (name === 'k256') {4938 -1 prime = new K256();4939 -1 } else if (name === 'p224') {4940 -1 prime = new P224();4941 -1 } else if (name === 'p192') {4942 -1 prime = new P192();4943 -1 } else if (name === 'p25519') {4944 -1 prime = new P25519();4945 -1 } else {4946 -1 throw new Error('Unknown prime ' + name);4947 -1 }4948 -1 primes[name] = prime;4949 -14950 -1 return prime;4951 -1 };4952 -14953 -1 //4954 -1 // Base reduction engine4955 -1 //4956 -1 function Red (m) {4957 -1 if (typeof m === 'string') {4958 -1 var prime = BN._prime(m);4959 -1 this.m = prime.p;4960 -1 this.prime = prime;4961 -1 } else {4962 -1 assert(m.gtn(1), 'modulus must be greater than 1');4963 -1 this.m = m;4964 -1 this.prime = null;4965 -1 }4966 -1 }4967 -14968 -1 Red.prototype._verify1 = function _verify1 (a) {4969 -1 assert(a.negative === 0, 'red works only with positives');4970 -1 assert(a.red, 'red works only with red numbers');4971 -1 };4972 -14973 -1 Red.prototype._verify2 = function _verify2 (a, b) {4974 -1 assert((a.negative | b.negative) === 0, 'red works only with positives');4975 -1 assert(a.red && a.red === b.red,4976 -1 'red works only with red numbers');4977 -1 };4978 -14979 -1 Red.prototype.imod = function imod (a) {4980 -1 if (this.prime) return this.prime.ireduce(a)._forceRed(this);4981 -1 return a.umod(this.m)._forceRed(this);4982 -1 };4983 -14984 -1 Red.prototype.neg = function neg (a) {4985 -1 if (a.isZero()) {4986 -1 return a.clone();4987 -1 }4988 -14989 -1 return this.m.sub(a)._forceRed(this);4990 -1 };4991 -14992 -1 Red.prototype.add = function add (a, b) {4993 -1 this._verify2(a, b);4994 -14995 -1 var res = a.add(b);4996 -1 if (res.cmp(this.m) >= 0) {4997 -1 res.isub(this.m);4998 -1 }4999 -1 return res._forceRed(this);5000 -1 };5001 -15002 -1 Red.prototype.iadd = function iadd (a, b) {5003 -1 this._verify2(a, b);5004 -15005 -1 var res = a.iadd(b);5006 -1 if (res.cmp(this.m) >= 0) {5007 -1 res.isub(this.m);5008 -1 }5009 -1 return res;5010 -1 };5011 -15012 -1 Red.prototype.sub = function sub (a, b) {5013 -1 this._verify2(a, b);5014 -15015 -1 var res = a.sub(b);5016 -1 if (res.cmpn(0) < 0) {5017 -1 res.iadd(this.m);5018 -1 }5019 -1 return res._forceRed(this);5020 -1 };5021 -15022 -1 Red.prototype.isub = function isub (a, b) {5023 -1 this._verify2(a, b);5024 -15025 -1 var res = a.isub(b);5026 -1 if (res.cmpn(0) < 0) {5027 -1 res.iadd(this.m);5028 -1 }5029 -1 return res;5030 -1 };5031 -15032 -1 Red.prototype.shl = function shl (a, num) {5033 -1 this._verify1(a);5034 -1 return this.imod(a.ushln(num));5035 -1 };5036 -15037 -1 Red.prototype.imul = function imul (a, b) {5038 -1 this._verify2(a, b);5039 -1 return this.imod(a.imul(b));5040 -1 };5041 -15042 -1 Red.prototype.mul = function mul (a, b) {5043 -1 this._verify2(a, b);5044 -1 return this.imod(a.mul(b));5045 -1 };5046 -15047 -1 Red.prototype.isqr = function isqr (a) {5048 -1 return this.imul(a, a.clone());5049 -1 };5050 -15051 -1 Red.prototype.sqr = function sqr (a) {5052 -1 return this.mul(a, a);5053 -1 };5054 -15055 -1 Red.prototype.sqrt = function sqrt (a) {5056 -1 if (a.isZero()) return a.clone();5057 -15058 -1 var mod3 = this.m.andln(3);5059 -1 assert(mod3 % 2 === 1);5060 -15061 -1 // Fast case5062 -1 if (mod3 === 3) {5063 -1 var pow = this.m.add(new BN(1)).iushrn(2);5064 -1 return this.pow(a, pow);5065 -1 }5066 -15067 -1 // Tonelli-Shanks algorithm (Totally unoptimized and slow)5068 -1 //5069 -1 // Find Q and S, that Q * 2 ^ S = (P - 1)5070 -1 var q = this.m.subn(1);5071 -1 var s = 0;5072 -1 while (!q.isZero() && q.andln(1) === 0) {5073 -1 s++;5074 -1 q.iushrn(1);5075 -1 }5076 -1 assert(!q.isZero());5077 -15078 -1 var one = new BN(1).toRed(this);5079 -1 var nOne = one.redNeg();5080 -15081 -1 // Find quadratic non-residue5082 -1 // NOTE: Max is such because of generalized Riemann hypothesis.5083 -1 var lpow = this.m.subn(1).iushrn(1);5084 -1 var z = this.m.bitLength();5085 -1 z = new BN(2 * z * z).toRed(this);5086 -15087 -1 while (this.pow(z, lpow).cmp(nOne) !== 0) {5088 -1 z.redIAdd(nOne);5089 -1 }5090 -15091 -1 var c = this.pow(z, q);5092 -1 var r = this.pow(a, q.addn(1).iushrn(1));5093 -1 var t = this.pow(a, q);5094 -1 var m = s;5095 -1 while (t.cmp(one) !== 0) {5096 -1 var tmp = t;5097 -1 for (var i = 0; tmp.cmp(one) !== 0; i++) {5098 -1 tmp = tmp.redSqr();5099 -1 }5100 -1 assert(i < m);5101 -1 var b = this.pow(c, new BN(1).iushln(m - i - 1));5102 -15103 -1 r = r.redMul(b);5104 -1 c = b.redSqr();5105 -1 t = t.redMul(c);5106 -1 m = i;5107 -1 }5108 -15109 -1 return r;5110 -1 };5111 -15112 -1 Red.prototype.invm = function invm (a) {5113 -1 var inv = a._invmp(this.m);5114 -1 if (inv.negative !== 0) {5115 -1 inv.negative = 0;5116 -1 return this.imod(inv).redNeg();5117 -1 } else {5118 -1 return this.imod(inv);5119 -1 }5120 -1 };5121 -15122 -1 Red.prototype.pow = function pow (a, num) {5123 -1 if (num.isZero()) return new BN(1).toRed(this);5124 -1 if (num.cmpn(1) === 0) return a.clone();5125 -15126 -1 var windowSize = 4;5127 -1 var wnd = new Array(1 << windowSize);5128 -1 wnd[0] = new BN(1).toRed(this);5129 -1 wnd[1] = a;5130 -1 for (var i = 2; i < wnd.length; i++) {5131 -1 wnd[i] = this.mul(wnd[i - 1], a);5132 -1 }5133 -15134 -1 var res = wnd[0];5135 -1 var current = 0;5136 -1 var currentLen = 0;5137 -1 var start = num.bitLength() % 26;5138 -1 if (start === 0) {5139 -1 start = 26;5140 -1 }5141 -15142 -1 for (i = num.length - 1; i >= 0; i--) {5143 -1 var word = num.words[i];5144 -1 for (var j = start - 1; j >= 0; j--) {5145 -1 var bit = (word >> j) & 1;5146 -1 if (res !== wnd[0]) {5147 -1 res = this.sqr(res);5148 -1 }5149 -15150 -1 if (bit === 0 && current === 0) {5151 -1 currentLen = 0;5152 -1 continue;5153 -1 }5154 -15155 -1 current <<= 1;5156 -1 current |= bit;5157 -1 currentLen++;5158 -1 if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;5159 -15160 -1 res = this.mul(res, wnd[current]);5161 -1 currentLen = 0;5162 -1 current = 0;5163 -1 }5164 -1 start = 26;5165 -1 }5166 -15167 -1 return res;5168 -1 };5169 -15170 -1 Red.prototype.convertTo = function convertTo (num) {5171 -1 var r = num.umod(this.m);5172 -15173 -1 return r === num ? r.clone() : r;5174 -1 };5175 -15176 -1 Red.prototype.convertFrom = function convertFrom (num) {5177 -1 var res = num.clone();5178 -1 res.red = null;5179 -1 return res;5180 -1 };5181 -15182 -1 //5183 -1 // Montgomery method engine5184 -1 //5185 -15186 -1 BN.mont = function mont (num) {5187 -1 return new Mont(num);5188 -1 };5189 -15190 -1 function Mont (m) {5191 -1 Red.call(this, m);5192 -15193 -1 this.shift = this.m.bitLength();5194 -1 if (this.shift % 26 !== 0) {5195 -1 this.shift += 26 - (this.shift % 26);5196 -1 }5197 -15198 -1 this.r = new BN(1).iushln(this.shift);5199 -1 this.r2 = this.imod(this.r.sqr());5200 -1 this.rinv = this.r._invmp(this.m);5201 -15202 -1 this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);5203 -1 this.minv = this.minv.umod(this.r);5204 -1 this.minv = this.r.sub(this.minv);5205 -1 }5206 -1 inherits(Mont, Red);5207 -15208 -1 Mont.prototype.convertTo = function convertTo (num) {5209 -1 return this.imod(num.ushln(this.shift));5210 -1 };5211 -15212 -1 Mont.prototype.convertFrom = function convertFrom (num) {5213 -1 var r = this.imod(num.mul(this.rinv));5214 -1 r.red = null;5215 -1 return r;5216 -1 };5217 -15218 -1 Mont.prototype.imul = function imul (a, b) {5219 -1 if (a.isZero() || b.isZero()) {5220 -1 a.words[0] = 0;5221 -1 a.length = 1;5222 -1 return a;5223 -1 }5224 -15225 -1 var t = a.imul(b);5226 -1 var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);5227 -1 var u = t.isub(c).iushrn(this.shift);5228 -1 var res = u;5229 -15230 -1 if (u.cmp(this.m) >= 0) {5231 -1 res = u.isub(this.m);5232 -1 } else if (u.cmpn(0) < 0) {5233 -1 res = u.iadd(this.m);5234 -1 }5235 -15236 -1 return res._forceRed(this);5237 -1 };5238 -15239 -1 Mont.prototype.mul = function mul (a, b) {5240 -1 if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);5241 -15242 -1 var t = a.mul(b);5243 -1 var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);5244 -1 var u = t.isub(c).iushrn(this.shift);5245 -1 var res = u;5246 -1 if (u.cmp(this.m) >= 0) {5247 -1 res = u.isub(this.m);5248 -1 } else if (u.cmpn(0) < 0) {5249 -1 res = u.iadd(this.m);5250 -1 }5251 -15252 -1 return res._forceRed(this);5253 -1 };5254 -15255 -1 Mont.prototype.invm = function invm (a) {5256 -1 // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R5257 -1 var res = this.imod(a._invmp(this.m).mul(this.r2));5258 -1 return res._forceRed(this);5259 -1 };5260 -1 })(typeof module === 'undefined' || module, this);5261 -15262 -1 },{"buffer":19}],16:[function(require,module,exports){5263 -1 'use strict'5264 -15265 -1 exports.byteLength = byteLength5266 -1 exports.toByteArray = toByteArray5267 -1 exports.fromByteArray = fromByteArray5268 -15269 -1 var lookup = []5270 -1 var revLookup = []5271 -1 var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array5272 -15273 -1 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'5274 -1 for (var i = 0, len = code.length; i < len; ++i) {5275 -1 lookup[i] = code[i]5276 -1 revLookup[code.charCodeAt(i)] = i5277 -1 }5278 -15279 -1 // Support decoding URL-safe base64 strings, as Node.js does.5280 -1 // See: https://en.wikipedia.org/wiki/Base64#URL_applications5281 -1 revLookup['-'.charCodeAt(0)] = 625282 -1 revLookup['_'.charCodeAt(0)] = 635283 -15284 -1 function getLens (b64) {5285 -1 var len = b64.length5286 -15287 -1 if (len % 4 > 0) {5288 -1 throw new Error('Invalid string. Length must be a multiple of 4')5289 -1 }5290 -15291 -1 // Trim off extra bytes after placeholder bytes are found5292 -1 // See: https://github.com/beatgammit/base64-js/issues/425293 -1 var validLen = b64.indexOf('=')5294 -1 if (validLen === -1) validLen = len5295 -15296 -1 var placeHoldersLen = validLen === len5297 -1 ? 05298 -1 : 4 - (validLen % 4)5299 -15300 -1 return [validLen, placeHoldersLen]5301 -1 }5302 -15303 -1 // base64 is 4/3 + up to two characters of the original data5304 -1 function byteLength (b64) {5305 -1 var lens = getLens(b64)5306 -1 var validLen = lens[0]5307 -1 var placeHoldersLen = lens[1]5308 -1 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen5309 -1 }5310 -15311 -1 function _byteLength (b64, validLen, placeHoldersLen) {5312 -1 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen5313 -1 }5314 -15315 -1 function toByteArray (b64) {5316 -1 var tmp5317 -1 var lens = getLens(b64)5318 -1 var validLen = lens[0]5319 -1 var placeHoldersLen = lens[1]5320 -15321 -1 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))5322 -15323 -1 var curByte = 05324 -15325 -1 // if there are placeholders, only get up to the last complete 4 chars5326 -1 var len = placeHoldersLen > 05327 -1 ? validLen - 45328 -1 : validLen5329 -15330 -1 var i5331 -1 for (i = 0; i < len; i += 4) {5332 -1 tmp =5333 -1 (revLookup[b64.charCodeAt(i)] << 18) |5334 -1 (revLookup[b64.charCodeAt(i + 1)] << 12) |5335 -1 (revLookup[b64.charCodeAt(i + 2)] << 6) |5336 -1 revLookup[b64.charCodeAt(i + 3)]5337 -1 arr[curByte++] = (tmp >> 16) & 0xFF5338 -1 arr[curByte++] = (tmp >> 8) & 0xFF5339 -1 arr[curByte++] = tmp & 0xFF5340 -1 }5341 -15342 -1 if (placeHoldersLen === 2) {5343 -1 tmp =5344 -1 (revLookup[b64.charCodeAt(i)] << 2) |5345 -1 (revLookup[b64.charCodeAt(i + 1)] >> 4)5346 -1 arr[curByte++] = tmp & 0xFF5347 -1 }5348 -15349 -1 if (placeHoldersLen === 1) {5350 -1 tmp =5351 -1 (revLookup[b64.charCodeAt(i)] << 10) |5352 -1 (revLookup[b64.charCodeAt(i + 1)] << 4) |5353 -1 (revLookup[b64.charCodeAt(i + 2)] >> 2)5354 -1 arr[curByte++] = (tmp >> 8) & 0xFF5355 -1 arr[curByte++] = tmp & 0xFF5356 -1 }5357 -15358 -1 return arr5359 -1 }5360 -15361 -1 function tripletToBase64 (num) {5362 -1 return lookup[num >> 18 & 0x3F] +5363 -1 lookup[num >> 12 & 0x3F] +5364 -1 lookup[num >> 6 & 0x3F] +5365 -1 lookup[num & 0x3F]5366 -1 }5367 -15368 -1 function encodeChunk (uint8, start, end) {5369 -1 var tmp5370 -1 var output = []5371 -1 for (var i = start; i < end; i += 3) {5372 -1 tmp =5373 -1 ((uint8[i] << 16) & 0xFF0000) +5374 -1 ((uint8[i + 1] << 8) & 0xFF00) +5375 -1 (uint8[i + 2] & 0xFF)5376 -1 output.push(tripletToBase64(tmp))5377 -1 }5378 -1 return output.join('')5379 -1 }5380 -15381 -1 function fromByteArray (uint8) {5382 -1 var tmp5383 -1 var len = uint8.length5384 -1 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes5385 -1 var parts = []5386 -1 var maxChunkLength = 16383 // must be multiple of 35387 -15388 -1 // go through the array every three bytes, we'll deal with trailing stuff later5389 -1 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {5390 -1 parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))5391 -1 }5392 -15393 -1 // pad the end with zeros, but make sure to not forget the extra bytes5394 -1 if (extraBytes === 1) {5395 -1 tmp = uint8[len - 1]5396 -1 parts.push(5397 -1 lookup[tmp >> 2] +5398 -1 lookup[(tmp << 4) & 0x3F] +5399 -1 '=='5400 -1 )5401 -1 } else if (extraBytes === 2) {5402 -1 tmp = (uint8[len - 2] << 8) + uint8[len - 1]5403 -1 parts.push(5404 -1 lookup[tmp >> 10] +5405 -1 lookup[(tmp >> 4) & 0x3F] +5406 -1 lookup[(tmp << 2) & 0x3F] +5407 -1 '='5408 -1 )5409 -1 }5410 -15411 -1 return parts.join('')5412 -1 }5413 -15414 -1 },{}],17:[function(require,module,exports){5415 -1 (function (module, exports) {5416 -1 'use strict';5417 -15418 -1 // Utils5419 -1 function assert (val, msg) {5420 -1 if (!val) throw new Error(msg || 'Assertion failed');5421 -1 }5422 -15423 -1 // Could use `inherits` module, but don't want to move from single file5424 -1 // architecture yet.5425 -1 function inherits (ctor, superCtor) {5426 -1 ctor.super_ = superCtor;5427 -1 var TempCtor = function () {};5428 -1 TempCtor.prototype = superCtor.prototype;5429 -1 ctor.prototype = new TempCtor();5430 -1 ctor.prototype.constructor = ctor;5431 -1 }5432 -15433 -1 // BN5434 -15435 -1 function BN (number, base, endian) {5436 -1 if (BN.isBN(number)) {5437 -1 return number;5438 -1 }5439 -15440 -1 this.negative = 0;5441 -1 this.words = null;5442 -1 this.length = 0;5443 -15444 -1 // Reduction context5445 -1 this.red = null;5446 -15447 -1 if (number !== null) {5448 -1 if (base === 'le' || base === 'be') {5449 -1 endian = base;5450 -1 base = 10;5451 -1 }5452 -15453 -1 this._init(number || 0, base || 10, endian || 'be');5454 -1 }5455 -1 }5456 -1 if (typeof module === 'object') {5457 -1 module.exports = BN;5458 -1 } else {5459 -1 exports.BN = BN;5460 -1 }5461 -15462 -1 BN.BN = BN;5463 -1 BN.wordSize = 26;5464 -15465 -1 var Buffer;5466 -1 try {5467 -1 if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {5468 -1 Buffer = window.Buffer;5469 -1 } else {5470 -1 Buffer = require('buffer').Buffer;5471 -1 }5472 -1 } catch (e) {5473 -1 }5474 -15475 -1 BN.isBN = function isBN (num) {5476 -1 if (num instanceof BN) {5477 -1 return true;5478 -1 }5479 -15480 -1 return num !== null && typeof num === 'object' &&5481 -1 num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);5482 -1 };5483 -15484 -1 BN.max = function max (left, right) {5485 -1 if (left.cmp(right) > 0) return left;5486 -1 return right;5487 -1 };5488 -15489 -1 BN.min = function min (left, right) {5490 -1 if (left.cmp(right) < 0) return left;5491 -1 return right;5492 -1 };5493 -15494 -1 BN.prototype._init = function init (number, base, endian) {5495 -1 if (typeof number === 'number') {5496 -1 return this._initNumber(number, base, endian);5497 -1 }5498 -15499 -1 if (typeof number === 'object') {5500 -1 return this._initArray(number, base, endian);5501 -1 }5502 -15503 -1 if (base === 'hex') {5504 -1 base = 16;5505 -1 }5506 -1 assert(base === (base | 0) && base >= 2 && base <= 36);5507 -15508 -1 number = number.toString().replace(/\s+/g, '');5509 -1 var start = 0;5510 -1 if (number[0] === '-') {5511 -1 start++;5512 -1 this.negative = 1;5513 -1 }5514 -15515 -1 if (start < number.length) {5516 -1 if (base === 16) {5517 -1 this._parseHex(number, start, endian);5518 -1 } else {5519 -1 this._parseBase(number, base, start);5520 -1 if (endian === 'le') {5521 -1 this._initArray(this.toArray(), base, endian);5522 -1 }5523 -1 }5524 -1 }5525 -1 };5526 -15527 -1 BN.prototype._initNumber = function _initNumber (number, base, endian) {5528 -1 if (number < 0) {5529 -1 this.negative = 1;5530 -1 number = -number;5531 -1 }5532 -1 if (number < 0x4000000) {5533 -1 this.words = [number & 0x3ffffff];5534 -1 this.length = 1;5535 -1 } else if (number < 0x10000000000000) {5536 -1 this.words = [5537 -1 number & 0x3ffffff,5538 -1 (number / 0x4000000) & 0x3ffffff5539 -1 ];5540 -1 this.length = 2;5541 -1 } else {5542 -1 assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)5543 -1 this.words = [5544 -1 number & 0x3ffffff,5545 -1 (number / 0x4000000) & 0x3ffffff,5546 -1 15547 -1 ];5548 -1 this.length = 3;5549 -1 }5550 -15551 -1 if (endian !== 'le') return;5552 -15553 -1 // Reverse the bytes5554 -1 this._initArray(this.toArray(), base, endian);5555 -1 };5556 -15557 -1 BN.prototype._initArray = function _initArray (number, base, endian) {5558 -1 // Perhaps a Uint8Array5559 -1 assert(typeof number.length === 'number');5560 -1 if (number.length <= 0) {5561 -1 this.words = [0];5562 -1 this.length = 1;5563 -1 return this;5564 -1 }5565 -15566 -1 this.length = Math.ceil(number.length / 3);5567 -1 this.words = new Array(this.length);5568 -1 for (var i = 0; i < this.length; i++) {5569 -1 this.words[i] = 0;5570 -1 }5571 -15572 -1 var j, w;5573 -1 var off = 0;5574 -1 if (endian === 'be') {5575 -1 for (i = number.length - 1, j = 0; i >= 0; i -= 3) {5576 -1 w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);5577 -1 this.words[j] |= (w << off) & 0x3ffffff;5578 -1 this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;5579 -1 off += 24;5580 -1 if (off >= 26) {5581 -1 off -= 26;5582 -1 j++;5583 -1 }5584 -1 }5585 -1 } else if (endian === 'le') {5586 -1 for (i = 0, j = 0; i < number.length; i += 3) {5587 -1 w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);5588 -1 this.words[j] |= (w << off) & 0x3ffffff;5589 -1 this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;5590 -1 off += 24;5591 -1 if (off >= 26) {5592 -1 off -= 26;5593 -1 j++;5594 -1 }5595 -1 }5596 -1 }5597 -1 return this._strip();5598 -1 };5599 -15600 -1 function parseHex4Bits (string, index) {5601 -1 var c = string.charCodeAt(index);5602 -1 // '0' - '9'5603 -1 if (c >= 48 && c <= 57) {5604 -1 return c - 48;5605 -1 // 'A' - 'F'5606 -1 } else if (c >= 65 && c <= 70) {5607 -1 return c - 55;5608 -1 // 'a' - 'f'5609 -1 } else if (c >= 97 && c <= 102) {5610 -1 return c - 87;5611 -1 } else {5612 -1 assert(false, 'Invalid character in ' + string);5613 -1 }5614 -1 }5615 -15616 -1 function parseHexByte (string, lowerBound, index) {5617 -1 var r = parseHex4Bits(string, index);5618 -1 if (index - 1 >= lowerBound) {5619 -1 r |= parseHex4Bits(string, index - 1) << 4;5620 -1 }5621 -1 return r;5622 -1 }5623 -15624 -1 BN.prototype._parseHex = function _parseHex (number, start, endian) {5625 -1 // Create possibly bigger array to ensure that it fits the number5626 -1 this.length = Math.ceil((number.length - start) / 6);5627 -1 this.words = new Array(this.length);5628 -1 for (var i = 0; i < this.length; i++) {5629 -1 this.words[i] = 0;5630 -1 }5631 -15632 -1 // 24-bits chunks5633 -1 var off = 0;5634 -1 var j = 0;5635 -15636 -1 var w;5637 -1 if (endian === 'be') {5638 -1 for (i = number.length - 1; i >= start; i -= 2) {5639 -1 w = parseHexByte(number, start, i) << off;5640 -1 this.words[j] |= w & 0x3ffffff;5641 -1 if (off >= 18) {5642 -1 off -= 18;5643 -1 j += 1;5644 -1 this.words[j] |= w >>> 26;5645 -1 } else {5646 -1 off += 8;5647 -1 }5648 -1 }5649 -1 } else {5650 -1 var parseLength = number.length - start;5651 -1 for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {5652 -1 w = parseHexByte(number, start, i) << off;5653 -1 this.words[j] |= w & 0x3ffffff;5654 -1 if (off >= 18) {5655 -1 off -= 18;5656 -1 j += 1;5657 -1 this.words[j] |= w >>> 26;5658 -1 } else {5659 -1 off += 8;5660 -1 }5661 -1 }5662 -1 }5663 -15664 -1 this._strip();5665 -1 };5666 -15667 -1 function parseBase (str, start, end, mul) {5668 -1 var r = 0;5669 -1 var b = 0;5670 -1 var len = Math.min(str.length, end);5671 -1 for (var i = start; i < len; i++) {5672 -1 var c = str.charCodeAt(i) - 48;5673 -15674 -1 r *= mul;5675 -15676 -1 // 'a'5677 -1 if (c >= 49) {5678 -1 b = c - 49 + 0xa;5679 -15680 -1 // 'A'5681 -1 } else if (c >= 17) {5682 -1 b = c - 17 + 0xa;5683 -15684 -1 // '0' - '9'5685 -1 } else {5686 -1 b = c;5687 -1 }5688 -1 assert(c >= 0 && b < mul, 'Invalid character');5689 -1 r += b;5690 -1 }5691 -1 return r;5692 -1 }5693 -15694 -1 BN.prototype._parseBase = function _parseBase (number, base, start) {5695 -1 // Initialize as zero5696 -1 this.words = [0];5697 -1 this.length = 1;5698 -15699 -1 // Find length of limb in base5700 -1 for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {5701 -1 limbLen++;5702 -1 }5703 -1 limbLen--;5704 -1 limbPow = (limbPow / base) | 0;5705 -15706 -1 var total = number.length - start;5707 -1 var mod = total % limbLen;5708 -1 var end = Math.min(total, total - mod) + start;5709 -15710 -1 var word = 0;5711 -1 for (var i = start; i < end; i += limbLen) {5712 -1 word = parseBase(number, i, i + limbLen, base);5713 -15714 -1 this.imuln(limbPow);5715 -1 if (this.words[0] + word < 0x4000000) {5716 -1 this.words[0] += word;5717 -1 } else {5718 -1 this._iaddn(word);5719 -1 }5720 -1 }5721 -15722 -1 if (mod !== 0) {5723 -1 var pow = 1;5724 -1 word = parseBase(number, i, number.length, base);5725 -15726 -1 for (i = 0; i < mod; i++) {5727 -1 pow *= base;5728 -1 }5729 -15730 -1 this.imuln(pow);5731 -1 if (this.words[0] + word < 0x4000000) {5732 -1 this.words[0] += word;5733 -1 } else {5734 -1 this._iaddn(word);5735 -1 }5736 -1 }5737 -15738 -1 this._strip();5739 -1 };5740 -15741 -1 BN.prototype.copy = function copy (dest) {5742 -1 dest.words = new Array(this.length);5743 -1 for (var i = 0; i < this.length; i++) {5744 -1 dest.words[i] = this.words[i];5745 -1 }5746 -1 dest.length = this.length;5747 -1 dest.negative = this.negative;5748 -1 dest.red = this.red;5749 -1 };5750 -15751 -1 function move (dest, src) {5752 -1 dest.words = src.words;5753 -1 dest.length = src.length;5754 -1 dest.negative = src.negative;5755 -1 dest.red = src.red;5756 -1 }5757 -15758 -1 BN.prototype._move = function _move (dest) {5759 -1 move(dest, this);5760 -1 };5761 -15762 -1 BN.prototype.clone = function clone () {5763 -1 var r = new BN(null);5764 -1 this.copy(r);5765 -1 return r;5766 -1 };5767 -15768 -1 BN.prototype._expand = function _expand (size) {5769 -1 while (this.length < size) {5770 -1 this.words[this.length++] = 0;5771 -1 }5772 -1 return this;5773 -1 };5774 -15775 -1 // Remove leading `0` from `this`5776 -1 BN.prototype._strip = function strip () {5777 -1 while (this.length > 1 && this.words[this.length - 1] === 0) {5778 -1 this.length--;5779 -1 }5780 -1 return this._normSign();5781 -1 };5782 -15783 -1 BN.prototype._normSign = function _normSign () {5784 -1 // -0 = 05785 -1 if (this.length === 1 && this.words[0] === 0) {5786 -1 this.negative = 0;5787 -1 }5788 -1 return this;5789 -1 };5790 -15791 -1 // Check Symbol.for because not everywhere where Symbol defined5792 -1 // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility5793 -1 if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') {5794 -1 try {5795 -1 BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect;5796 -1 } catch (e) {5797 -1 BN.prototype.inspect = inspect;5798 -1 }5799 -1 } else {5800 -1 BN.prototype.inspect = inspect;5801 -1 }5802 -15803 -1 function inspect () {5804 -1 return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';5805 -1 }5806 -15807 -1 /*5808 -15809 -1 var zeros = [];5810 -1 var groupSizes = [];5811 -1 var groupBases = [];5812 -15813 -1 var s = '';5814 -1 var i = -1;5815 -1 while (++i < BN.wordSize) {5816 -1 zeros[i] = s;5817 -1 s += '0';5818 -1 }5819 -1 groupSizes[0] = 0;5820 -1 groupSizes[1] = 0;5821 -1 groupBases[0] = 0;5822 -1 groupBases[1] = 0;5823 -1 var base = 2 - 1;5824 -1 while (++base < 36 + 1) {5825 -1 var groupSize = 0;5826 -1 var groupBase = 1;5827 -1 while (groupBase < (1 << BN.wordSize) / base) {5828 -1 groupBase *= base;5829 -1 groupSize += 1;5830 -1 }5831 -1 groupSizes[base] = groupSize;5832 -1 groupBases[base] = groupBase;5833 -1 }5834 -15835 -1 */5836 -15837 -1 var zeros = [5838 -1 '',5839 -1 '0',5840 -1 '00',5841 -1 '000',5842 -1 '0000',5843 -1 '00000',5844 -1 '000000',5845 -1 '0000000',5846 -1 '00000000',5847 -1 '000000000',5848 -1 '0000000000',5849 -1 '00000000000',5850 -1 '000000000000',5851 -1 '0000000000000',5852 -1 '00000000000000',5853 -1 '000000000000000',5854 -1 '0000000000000000',5855 -1 '00000000000000000',5856 -1 '000000000000000000',5857 -1 '0000000000000000000',5858 -1 '00000000000000000000',5859 -1 '000000000000000000000',5860 -1 '0000000000000000000000',5861 -1 '00000000000000000000000',5862 -1 '000000000000000000000000',5863 -1 '0000000000000000000000000'5864 -1 ];5865 -15866 -1 var groupSizes = [5867 -1 0, 0,5868 -1 25, 16, 12, 11, 10, 9, 8,5869 -1 8, 7, 7, 7, 7, 6, 6,5870 -1 6, 6, 6, 6, 6, 5, 5,5871 -1 5, 5, 5, 5, 5, 5, 5,5872 -1 5, 5, 5, 5, 5, 5, 55873 -1 ];5874 -15875 -1 var groupBases = [5876 -1 0, 0,5877 -1 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,5878 -1 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,5879 -1 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,5880 -1 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,5881 -1 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 604661765882 -1 ];5883 -15884 -1 BN.prototype.toString = function toString (base, padding) {5885 -1 base = base || 10;5886 -1 padding = padding | 0 || 1;5887 -15888 -1 var out;5889 -1 if (base === 16 || base === 'hex') {5890 -1 out = '';5891 -1 var off = 0;5892 -1 var carry = 0;5893 -1 for (var i = 0; i < this.length; i++) {5894 -1 var w = this.words[i];5895 -1 var word = (((w << off) | carry) & 0xffffff).toString(16);5896 -1 carry = (w >>> (24 - off)) & 0xffffff;5897 -1 if (carry !== 0 || i !== this.length - 1) {5898 -1 out = zeros[6 - word.length] + word + out;5899 -1 } else {5900 -1 out = word + out;5901 -1 }5902 -1 off += 2;5903 -1 if (off >= 26) {5904 -1 off -= 26;5905 -1 i--;5906 -1 }5907 -1 }5908 -1 if (carry !== 0) {5909 -1 out = carry.toString(16) + out;5910 -1 }5911 -1 while (out.length % padding !== 0) {5912 -1 out = '0' + out;5913 -1 }5914 -1 if (this.negative !== 0) {5915 -1 out = '-' + out;5916 -1 }5917 -1 return out;5918 -1 }5919 -15920 -1 if (base === (base | 0) && base >= 2 && base <= 36) {5921 -1 // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));5922 -1 var groupSize = groupSizes[base];5923 -1 // var groupBase = Math.pow(base, groupSize);5924 -1 var groupBase = groupBases[base];5925 -1 out = '';5926 -1 var c = this.clone();5927 -1 c.negative = 0;5928 -1 while (!c.isZero()) {5929 -1 var r = c.modrn(groupBase).toString(base);5930 -1 c = c.idivn(groupBase);5931 -15932 -1 if (!c.isZero()) {5933 -1 out = zeros[groupSize - r.length] + r + out;5934 -1 } else {5935 -1 out = r + out;5936 -1 }5937 -1 }5938 -1 if (this.isZero()) {5939 -1 out = '0' + out;5940 -1 }5941 -1 while (out.length % padding !== 0) {5942 -1 out = '0' + out;5943 -1 }5944 -1 if (this.negative !== 0) {5945 -1 out = '-' + out;5946 -1 }5947 -1 return out;5948 -1 }5949 -15950 -1 assert(false, 'Base should be between 2 and 36');5951 -1 };5952 -15953 -1 BN.prototype.toNumber = function toNumber () {5954 -1 var ret = this.words[0];5955 -1 if (this.length === 2) {5956 -1 ret += this.words[1] * 0x4000000;5957 -1 } else if (this.length === 3 && this.words[2] === 0x01) {5958 -1 // NOTE: at this stage it is known that the top bit is set5959 -1 ret += 0x10000000000000 + (this.words[1] * 0x4000000);5960 -1 } else if (this.length > 2) {5961 -1 assert(false, 'Number can only safely store up to 53 bits');5962 -1 }5963 -1 return (this.negative !== 0) ? -ret : ret;5964 -1 };5965 -15966 -1 BN.prototype.toJSON = function toJSON () {5967 -1 return this.toString(16, 2);5968 -1 };5969 -15970 -1 if (Buffer) {5971 -1 BN.prototype.toBuffer = function toBuffer (endian, length) {5972 -1 return this.toArrayLike(Buffer, endian, length);5973 -1 };5974 -1 }5975 -15976 -1 BN.prototype.toArray = function toArray (endian, length) {5977 -1 return this.toArrayLike(Array, endian, length);5978 -1 };5979 -15980 -1 var allocate = function allocate (ArrayType, size) {5981 -1 if (ArrayType.allocUnsafe) {5982 -1 return ArrayType.allocUnsafe(size);5983 -1 }5984 -1 return new ArrayType(size);5985 -1 };5986 -15987 -1 BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {5988 -1 this._strip();5989 -15990 -1 var byteLength = this.byteLength();5991 -1 var reqLength = length || Math.max(1, byteLength);5992 -1 assert(byteLength <= reqLength, 'byte array longer than desired length');5993 -1 assert(reqLength > 0, 'Requested array length <= 0');5994 -15995 -1 var res = allocate(ArrayType, reqLength);5996 -1 var postfix = endian === 'le' ? 'LE' : 'BE';5997 -1 this['_toArrayLike' + postfix](res, byteLength);5998 -1 return res;5999 -1 };6000 -16001 -1 BN.prototype._toArrayLikeLE = function _toArrayLikeLE (res, byteLength) {6002 -1 var position = 0;6003 -1 var carry = 0;6004 -16005 -1 for (var i = 0, shift = 0; i < this.length; i++) {6006 -1 var word = (this.words[i] << shift) | carry;6007 -16008 -1 res[position++] = word & 0xff;6009 -1 if (position < res.length) {6010 -1 res[position++] = (word >> 8) & 0xff;6011 -1 }6012 -1 if (position < res.length) {6013 -1 res[position++] = (word >> 16) & 0xff;6014 -1 }6015 -16016 -1 if (shift === 6) {6017 -1 if (position < res.length) {6018 -1 res[position++] = (word >> 24) & 0xff;6019 -1 }6020 -1 carry = 0;6021 -1 shift = 0;6022 -1 } else {6023 -1 carry = word >>> 24;6024 -1 shift += 2;6025 -1 }6026 -1 }6027 -16028 -1 if (position < res.length) {6029 -1 res[position++] = carry;6030 -16031 -1 while (position < res.length) {6032 -1 res[position++] = 0;6033 -1 }6034 -1 }6035 -1 };6036 -16037 -1 BN.prototype._toArrayLikeBE = function _toArrayLikeBE (res, byteLength) {6038 -1 var position = res.length - 1;6039 -1 var carry = 0;6040 -16041 -1 for (var i = 0, shift = 0; i < this.length; i++) {6042 -1 var word = (this.words[i] << shift) | carry;6043 -16044 -1 res[position--] = word & 0xff;6045 -1 if (position >= 0) {6046 -1 res[position--] = (word >> 8) & 0xff;6047 -1 }6048 -1 if (position >= 0) {6049 -1 res[position--] = (word >> 16) & 0xff;6050 -1 }6051 -16052 -1 if (shift === 6) {6053 -1 if (position >= 0) {6054 -1 res[position--] = (word >> 24) & 0xff;6055 -1 }6056 -1 carry = 0;6057 -1 shift = 0;6058 -1 } else {6059 -1 carry = word >>> 24;6060 -1 shift += 2;6061 -1 }6062 -1 }6063 -16064 -1 if (position >= 0) {6065 -1 res[position--] = carry;6066 -16067 -1 while (position >= 0) {6068 -1 res[position--] = 0;6069 -1 }6070 -1 }6071 -1 };6072 -16073 -1 if (Math.clz32) {6074 -1 BN.prototype._countBits = function _countBits (w) {6075 -1 return 32 - Math.clz32(w);6076 -1 };6077 -1 } else {6078 -1 BN.prototype._countBits = function _countBits (w) {6079 -1 var t = w;6080 -1 var r = 0;6081 -1 if (t >= 0x1000) {6082 -1 r += 13;6083 -1 t >>>= 13;6084 -1 }6085 -1 if (t >= 0x40) {6086 -1 r += 7;6087 -1 t >>>= 7;6088 -1 }6089 -1 if (t >= 0x8) {6090 -1 r += 4;6091 -1 t >>>= 4;6092 -1 }6093 -1 if (t >= 0x02) {6094 -1 r += 2;6095 -1 t >>>= 2;6096 -1 }6097 -1 return r + t;6098 -1 };6099 -1 }6100 -16101 -1 BN.prototype._zeroBits = function _zeroBits (w) {6102 -1 // Short-cut6103 -1 if (w === 0) return 26;6104 -16105 -1 var t = w;6106 -1 var r = 0;6107 -1 if ((t & 0x1fff) === 0) {6108 -1 r += 13;6109 -1 t >>>= 13;6110 -1 }6111 -1 if ((t & 0x7f) === 0) {6112 -1 r += 7;6113 -1 t >>>= 7;6114 -1 }6115 -1 if ((t & 0xf) === 0) {6116 -1 r += 4;6117 -1 t >>>= 4;6118 -1 }6119 -1 if ((t & 0x3) === 0) {6120 -1 r += 2;6121 -1 t >>>= 2;6122 -1 }6123 -1 if ((t & 0x1) === 0) {6124 -1 r++;6125 -1 }6126 -1 return r;6127 -1 };6128 -16129 -1 // Return number of used bits in a BN6130 -1 BN.prototype.bitLength = function bitLength () {6131 -1 var w = this.words[this.length - 1];6132 -1 var hi = this._countBits(w);6133 -1 return (this.length - 1) * 26 + hi;6134 -1 };6135 -16136 -1 function toBitArray (num) {6137 -1 var w = new Array(num.bitLength());6138 -16139 -1 for (var bit = 0; bit < w.length; bit++) {6140 -1 var off = (bit / 26) | 0;6141 -1 var wbit = bit % 26;6142 -16143 -1 w[bit] = (num.words[off] >>> wbit) & 0x01;6144 -1 }6145 -16146 -1 return w;6147 -1 }6148 -16149 -1 // Number of trailing zero bits6150 -1 BN.prototype.zeroBits = function zeroBits () {6151 -1 if (this.isZero()) return 0;6152 -16153 -1 var r = 0;6154 -1 for (var i = 0; i < this.length; i++) {6155 -1 var b = this._zeroBits(this.words[i]);6156 -1 r += b;6157 -1 if (b !== 26) break;6158 -1 }6159 -1 return r;6160 -1 };6161 -16162 -1 BN.prototype.byteLength = function byteLength () {6163 -1 return Math.ceil(this.bitLength() / 8);6164 -1 };6165 -16166 -1 BN.prototype.toTwos = function toTwos (width) {6167 -1 if (this.negative !== 0) {6168 -1 return this.abs().inotn(width).iaddn(1);6169 -1 }6170 -1 return this.clone();6171 -1 };6172 -16173 -1 BN.prototype.fromTwos = function fromTwos (width) {6174 -1 if (this.testn(width - 1)) {6175 -1 return this.notn(width).iaddn(1).ineg();6176 -1 }6177 -1 return this.clone();6178 -1 };6179 -16180 -1 BN.prototype.isNeg = function isNeg () {6181 -1 return this.negative !== 0;6182 -1 };6183 -16184 -1 // Return negative clone of `this`6185 -1 BN.prototype.neg = function neg () {6186 -1 return this.clone().ineg();6187 -1 };6188 -16189 -1 BN.prototype.ineg = function ineg () {6190 -1 if (!this.isZero()) {6191 -1 this.negative ^= 1;6192 -1 }6193 -16194 -1 return this;6195 -1 };6196 -16197 -1 // Or `num` with `this` in-place6198 -1 BN.prototype.iuor = function iuor (num) {6199 -1 while (this.length < num.length) {6200 -1 this.words[this.length++] = 0;6201 -1 }6202 -16203 -1 for (var i = 0; i < num.length; i++) {6204 -1 this.words[i] = this.words[i] | num.words[i];6205 -1 }6206 -16207 -1 return this._strip();6208 -1 };6209 -16210 -1 BN.prototype.ior = function ior (num) {6211 -1 assert((this.negative | num.negative) === 0);6212 -1 return this.iuor(num);6213 -1 };6214 -16215 -1 // Or `num` with `this`6216 -1 BN.prototype.or = function or (num) {6217 -1 if (this.length > num.length) return this.clone().ior(num);6218 -1 return num.clone().ior(this);6219 -1 };6220 -16221 -1 BN.prototype.uor = function uor (num) {6222 -1 if (this.length > num.length) return this.clone().iuor(num);6223 -1 return num.clone().iuor(this);6224 -1 };6225 -16226 -1 // And `num` with `this` in-place6227 -1 BN.prototype.iuand = function iuand (num) {6228 -1 // b = min-length(num, this)6229 -1 var b;6230 -1 if (this.length > num.length) {6231 -1 b = num;6232 -1 } else {6233 -1 b = this;6234 -1 }6235 -16236 -1 for (var i = 0; i < b.length; i++) {6237 -1 this.words[i] = this.words[i] & num.words[i];6238 -1 }6239 -16240 -1 this.length = b.length;6241 -16242 -1 return this._strip();6243 -1 };6244 -16245 -1 BN.prototype.iand = function iand (num) {6246 -1 assert((this.negative | num.negative) === 0);6247 -1 return this.iuand(num);6248 -1 };6249 -16250 -1 // And `num` with `this`6251 -1 BN.prototype.and = function and (num) {6252 -1 if (this.length > num.length) return this.clone().iand(num);6253 -1 return num.clone().iand(this);6254 -1 };6255 -16256 -1 BN.prototype.uand = function uand (num) {6257 -1 if (this.length > num.length) return this.clone().iuand(num);6258 -1 return num.clone().iuand(this);6259 -1 };6260 -16261 -1 // Xor `num` with `this` in-place6262 -1 BN.prototype.iuxor = function iuxor (num) {6263 -1 // a.length > b.length6264 -1 var a;6265 -1 var b;6266 -1 if (this.length > num.length) {6267 -1 a = this;6268 -1 b = num;6269 -1 } else {6270 -1 a = num;6271 -1 b = this;6272 -1 }6273 -16274 -1 for (var i = 0; i < b.length; i++) {6275 -1 this.words[i] = a.words[i] ^ b.words[i];6276 -1 }6277 -16278 -1 if (this !== a) {6279 -1 for (; i < a.length; i++) {6280 -1 this.words[i] = a.words[i];6281 -1 }6282 -1 }6283 -16284 -1 this.length = a.length;6285 -16286 -1 return this._strip();6287 -1 };6288 -16289 -1 BN.prototype.ixor = function ixor (num) {6290 -1 assert((this.negative | num.negative) === 0);6291 -1 return this.iuxor(num);6292 -1 };6293 -16294 -1 // Xor `num` with `this`6295 -1 BN.prototype.xor = function xor (num) {6296 -1 if (this.length > num.length) return this.clone().ixor(num);6297 -1 return num.clone().ixor(this);6298 -1 };6299 -16300 -1 BN.prototype.uxor = function uxor (num) {6301 -1 if (this.length > num.length) return this.clone().iuxor(num);6302 -1 return num.clone().iuxor(this);6303 -1 };6304 -16305 -1 // Not ``this`` with ``width`` bitwidth6306 -1 BN.prototype.inotn = function inotn (width) {6307 -1 assert(typeof width === 'number' && width >= 0);6308 -16309 -1 var bytesNeeded = Math.ceil(width / 26) | 0;6310 -1 var bitsLeft = width % 26;6311 -16312 -1 // Extend the buffer with leading zeroes6313 -1 this._expand(bytesNeeded);6314 -16315 -1 if (bitsLeft > 0) {6316 -1 bytesNeeded--;6317 -1 }6318 -16319 -1 // Handle complete words6320 -1 for (var i = 0; i < bytesNeeded; i++) {6321 -1 this.words[i] = ~this.words[i] & 0x3ffffff;6322 -1 }6323 -16324 -1 // Handle the residue6325 -1 if (bitsLeft > 0) {6326 -1 this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));6327 -1 }6328 -16329 -1 // And remove leading zeroes6330 -1 return this._strip();6331 -1 };6332 -16333 -1 BN.prototype.notn = function notn (width) {6334 -1 return this.clone().inotn(width);6335 -1 };6336 -16337 -1 // Set `bit` of `this`6338 -1 BN.prototype.setn = function setn (bit, val) {6339 -1 assert(typeof bit === 'number' && bit >= 0);6340 -16341 -1 var off = (bit / 26) | 0;6342 -1 var wbit = bit % 26;6343 -16344 -1 this._expand(off + 1);6345 -16346 -1 if (val) {6347 -1 this.words[off] = this.words[off] | (1 << wbit);6348 -1 } else {6349 -1 this.words[off] = this.words[off] & ~(1 << wbit);6350 -1 }6351 -16352 -1 return this._strip();6353 -1 };6354 -16355 -1 // Add `num` to `this` in-place6356 -1 BN.prototype.iadd = function iadd (num) {6357 -1 var r;6358 -16359 -1 // negative + positive6360 -1 if (this.negative !== 0 && num.negative === 0) {6361 -1 this.negative = 0;6362 -1 r = this.isub(num);6363 -1 this.negative ^= 1;6364 -1 return this._normSign();6365 -16366 -1 // positive + negative6367 -1 } else if (this.negative === 0 && num.negative !== 0) {6368 -1 num.negative = 0;6369 -1 r = this.isub(num);6370 -1 num.negative = 1;6371 -1 return r._normSign();6372 -1 }6373 -16374 -1 // a.length > b.length6375 -1 var a, b;6376 -1 if (this.length > num.length) {6377 -1 a = this;6378 -1 b = num;6379 -1 } else {6380 -1 a = num;6381 -1 b = this;6382 -1 }6383 -16384 -1 var carry = 0;6385 -1 for (var i = 0; i < b.length; i++) {6386 -1 r = (a.words[i] | 0) + (b.words[i] | 0) + carry;6387 -1 this.words[i] = r & 0x3ffffff;6388 -1 carry = r >>> 26;6389 -1 }6390 -1 for (; carry !== 0 && i < a.length; i++) {6391 -1 r = (a.words[i] | 0) + carry;6392 -1 this.words[i] = r & 0x3ffffff;6393 -1 carry = r >>> 26;6394 -1 }6395 -16396 -1 this.length = a.length;6397 -1 if (carry !== 0) {6398 -1 this.words[this.length] = carry;6399 -1 this.length++;6400 -1 // Copy the rest of the words6401 -1 } else if (a !== this) {6402 -1 for (; i < a.length; i++) {6403 -1 this.words[i] = a.words[i];6404 -1 }6405 -1 }6406 -16407 -1 return this;6408 -1 };6409 -16410 -1 // Add `num` to `this`6411 -1 BN.prototype.add = function add (num) {6412 -1 var res;6413 -1 if (num.negative !== 0 && this.negative === 0) {6414 -1 num.negative = 0;6415 -1 res = this.sub(num);6416 -1 num.negative ^= 1;6417 -1 return res;6418 -1 } else if (num.negative === 0 && this.negative !== 0) {6419 -1 this.negative = 0;6420 -1 res = num.sub(this);6421 -1 this.negative = 1;6422 -1 return res;6423 -1 }6424 -16425 -1 if (this.length > num.length) return this.clone().iadd(num);6426 -16427 -1 return num.clone().iadd(this);6428 -1 };6429 -16430 -1 // Subtract `num` from `this` in-place6431 -1 BN.prototype.isub = function isub (num) {6432 -1 // this - (-num) = this + num6433 -1 if (num.negative !== 0) {6434 -1 num.negative = 0;6435 -1 var r = this.iadd(num);6436 -1 num.negative = 1;6437 -1 return r._normSign();6438 -16439 -1 // -this - num = -(this + num)6440 -1 } else if (this.negative !== 0) {6441 -1 this.negative = 0;6442 -1 this.iadd(num);6443 -1 this.negative = 1;6444 -1 return this._normSign();6445 -1 }6446 -16447 -1 // At this point both numbers are positive6448 -1 var cmp = this.cmp(num);6449 -16450 -1 // Optimization - zeroify6451 -1 if (cmp === 0) {6452 -1 this.negative = 0;6453 -1 this.length = 1;6454 -1 this.words[0] = 0;6455 -1 return this;6456 -1 }6457 -16458 -1 // a > b6459 -1 var a, b;6460 -1 if (cmp > 0) {6461 -1 a = this;6462 -1 b = num;6463 -1 } else {6464 -1 a = num;6465 -1 b = this;6466 -1 }6467 -16468 -1 var carry = 0;6469 -1 for (var i = 0; i < b.length; i++) {6470 -1 r = (a.words[i] | 0) - (b.words[i] | 0) + carry;6471 -1 carry = r >> 26;6472 -1 this.words[i] = r & 0x3ffffff;6473 -1 }6474 -1 for (; carry !== 0 && i < a.length; i++) {6475 -1 r = (a.words[i] | 0) + carry;6476 -1 carry = r >> 26;6477 -1 this.words[i] = r & 0x3ffffff;6478 -1 }6479 -16480 -1 // Copy rest of the words6481 -1 if (carry === 0 && i < a.length && a !== this) {6482 -1 for (; i < a.length; i++) {6483 -1 this.words[i] = a.words[i];6484 -1 }6485 -1 }6486 -16487 -1 this.length = Math.max(this.length, i);6488 -16489 -1 if (a !== this) {6490 -1 this.negative = 1;6491 -1 }6492 -16493 -1 return this._strip();6494 -1 };6495 -16496 -1 // Subtract `num` from `this`6497 -1 BN.prototype.sub = function sub (num) {6498 -1 return this.clone().isub(num);6499 -1 };6500 -16501 -1 function smallMulTo (self, num, out) {6502 -1 out.negative = num.negative ^ self.negative;6503 -1 var len = (self.length + num.length) | 0;6504 -1 out.length = len;6505 -1 len = (len - 1) | 0;6506 -16507 -1 // Peel one iteration (compiler can't do it, because of code complexity)6508 -1 var a = self.words[0] | 0;6509 -1 var b = num.words[0] | 0;6510 -1 var r = a * b;6511 -16512 -1 var lo = r & 0x3ffffff;6513 -1 var carry = (r / 0x4000000) | 0;6514 -1 out.words[0] = lo;6515 -16516 -1 for (var k = 1; k < len; k++) {6517 -1 // Sum all words with the same `i + j = k` and accumulate `ncarry`,6518 -1 // note that ncarry could be >= 0x3ffffff6519 -1 var ncarry = carry >>> 26;6520 -1 var rword = carry & 0x3ffffff;6521 -1 var maxJ = Math.min(k, num.length - 1);6522 -1 for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {6523 -1 var i = (k - j) | 0;6524 -1 a = self.words[i] | 0;6525 -1 b = num.words[j] | 0;6526 -1 r = a * b + rword;6527 -1 ncarry += (r / 0x4000000) | 0;6528 -1 rword = r & 0x3ffffff;6529 -1 }6530 -1 out.words[k] = rword | 0;6531 -1 carry = ncarry | 0;6532 -1 }6533 -1 if (carry !== 0) {6534 -1 out.words[k] = carry | 0;6535 -1 } else {6536 -1 out.length--;6537 -1 }6538 -16539 -1 return out._strip();6540 -1 }6541 -16542 -1 // TODO(indutny): it may be reasonable to omit it for users who don't need6543 -1 // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit6544 -1 // multiplication (like elliptic secp256k1).6545 -1 var comb10MulTo = function comb10MulTo (self, num, out) {6546 -1 var a = self.words;6547 -1 var b = num.words;6548 -1 var o = out.words;6549 -1 var c = 0;6550 -1 var lo;6551 -1 var mid;6552 -1 var hi;6553 -1 var a0 = a[0] | 0;6554 -1 var al0 = a0 & 0x1fff;6555 -1 var ah0 = a0 >>> 13;6556 -1 var a1 = a[1] | 0;6557 -1 var al1 = a1 & 0x1fff;6558 -1 var ah1 = a1 >>> 13;6559 -1 var a2 = a[2] | 0;6560 -1 var al2 = a2 & 0x1fff;6561 -1 var ah2 = a2 >>> 13;6562 -1 var a3 = a[3] | 0;6563 -1 var al3 = a3 & 0x1fff;6564 -1 var ah3 = a3 >>> 13;6565 -1 var a4 = a[4] | 0;6566 -1 var al4 = a4 & 0x1fff;6567 -1 var ah4 = a4 >>> 13;6568 -1 var a5 = a[5] | 0;6569 -1 var al5 = a5 & 0x1fff;6570 -1 var ah5 = a5 >>> 13;6571 -1 var a6 = a[6] | 0;6572 -1 var al6 = a6 & 0x1fff;6573 -1 var ah6 = a6 >>> 13;6574 -1 var a7 = a[7] | 0;6575 -1 var al7 = a7 & 0x1fff;6576 -1 var ah7 = a7 >>> 13;6577 -1 var a8 = a[8] | 0;6578 -1 var al8 = a8 & 0x1fff;6579 -1 var ah8 = a8 >>> 13;6580 -1 var a9 = a[9] | 0;6581 -1 var al9 = a9 & 0x1fff;6582 -1 var ah9 = a9 >>> 13;6583 -1 var b0 = b[0] | 0;6584 -1 var bl0 = b0 & 0x1fff;6585 -1 var bh0 = b0 >>> 13;6586 -1 var b1 = b[1] | 0;6587 -1 var bl1 = b1 & 0x1fff;6588 -1 var bh1 = b1 >>> 13;6589 -1 var b2 = b[2] | 0;6590 -1 var bl2 = b2 & 0x1fff;6591 -1 var bh2 = b2 >>> 13;6592 -1 var b3 = b[3] | 0;6593 -1 var bl3 = b3 & 0x1fff;6594 -1 var bh3 = b3 >>> 13;6595 -1 var b4 = b[4] | 0;6596 -1 var bl4 = b4 & 0x1fff;6597 -1 var bh4 = b4 >>> 13;6598 -1 var b5 = b[5] | 0;6599 -1 var bl5 = b5 & 0x1fff;6600 -1 var bh5 = b5 >>> 13;6601 -1 var b6 = b[6] | 0;6602 -1 var bl6 = b6 & 0x1fff;6603 -1 var bh6 = b6 >>> 13;6604 -1 var b7 = b[7] | 0;6605 -1 var bl7 = b7 & 0x1fff;6606 -1 var bh7 = b7 >>> 13;6607 -1 var b8 = b[8] | 0;6608 -1 var bl8 = b8 & 0x1fff;6609 -1 var bh8 = b8 >>> 13;6610 -1 var b9 = b[9] | 0;6611 -1 var bl9 = b9 & 0x1fff;6612 -1 var bh9 = b9 >>> 13;6613 -16614 -1 out.negative = self.negative ^ num.negative;6615 -1 out.length = 19;6616 -1 /* k = 0 */6617 -1 lo = Math.imul(al0, bl0);6618 -1 mid = Math.imul(al0, bh0);6619 -1 mid = (mid + Math.imul(ah0, bl0)) | 0;6620 -1 hi = Math.imul(ah0, bh0);6621 -1 var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6622 -1 c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;6623 -1 w0 &= 0x3ffffff;6624 -1 /* k = 1 */6625 -1 lo = Math.imul(al1, bl0);6626 -1 mid = Math.imul(al1, bh0);6627 -1 mid = (mid + Math.imul(ah1, bl0)) | 0;6628 -1 hi = Math.imul(ah1, bh0);6629 -1 lo = (lo + Math.imul(al0, bl1)) | 0;6630 -1 mid = (mid + Math.imul(al0, bh1)) | 0;6631 -1 mid = (mid + Math.imul(ah0, bl1)) | 0;6632 -1 hi = (hi + Math.imul(ah0, bh1)) | 0;6633 -1 var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6634 -1 c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;6635 -1 w1 &= 0x3ffffff;6636 -1 /* k = 2 */6637 -1 lo = Math.imul(al2, bl0);6638 -1 mid = Math.imul(al2, bh0);6639 -1 mid = (mid + Math.imul(ah2, bl0)) | 0;6640 -1 hi = Math.imul(ah2, bh0);6641 -1 lo = (lo + Math.imul(al1, bl1)) | 0;6642 -1 mid = (mid + Math.imul(al1, bh1)) | 0;6643 -1 mid = (mid + Math.imul(ah1, bl1)) | 0;6644 -1 hi = (hi + Math.imul(ah1, bh1)) | 0;6645 -1 lo = (lo + Math.imul(al0, bl2)) | 0;6646 -1 mid = (mid + Math.imul(al0, bh2)) | 0;6647 -1 mid = (mid + Math.imul(ah0, bl2)) | 0;6648 -1 hi = (hi + Math.imul(ah0, bh2)) | 0;6649 -1 var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6650 -1 c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;6651 -1 w2 &= 0x3ffffff;6652 -1 /* k = 3 */6653 -1 lo = Math.imul(al3, bl0);6654 -1 mid = Math.imul(al3, bh0);6655 -1 mid = (mid + Math.imul(ah3, bl0)) | 0;6656 -1 hi = Math.imul(ah3, bh0);6657 -1 lo = (lo + Math.imul(al2, bl1)) | 0;6658 -1 mid = (mid + Math.imul(al2, bh1)) | 0;6659 -1 mid = (mid + Math.imul(ah2, bl1)) | 0;6660 -1 hi = (hi + Math.imul(ah2, bh1)) | 0;6661 -1 lo = (lo + Math.imul(al1, bl2)) | 0;6662 -1 mid = (mid + Math.imul(al1, bh2)) | 0;6663 -1 mid = (mid + Math.imul(ah1, bl2)) | 0;6664 -1 hi = (hi + Math.imul(ah1, bh2)) | 0;6665 -1 lo = (lo + Math.imul(al0, bl3)) | 0;6666 -1 mid = (mid + Math.imul(al0, bh3)) | 0;6667 -1 mid = (mid + Math.imul(ah0, bl3)) | 0;6668 -1 hi = (hi + Math.imul(ah0, bh3)) | 0;6669 -1 var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6670 -1 c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;6671 -1 w3 &= 0x3ffffff;6672 -1 /* k = 4 */6673 -1 lo = Math.imul(al4, bl0);6674 -1 mid = Math.imul(al4, bh0);6675 -1 mid = (mid + Math.imul(ah4, bl0)) | 0;6676 -1 hi = Math.imul(ah4, bh0);6677 -1 lo = (lo + Math.imul(al3, bl1)) | 0;6678 -1 mid = (mid + Math.imul(al3, bh1)) | 0;6679 -1 mid = (mid + Math.imul(ah3, bl1)) | 0;6680 -1 hi = (hi + Math.imul(ah3, bh1)) | 0;6681 -1 lo = (lo + Math.imul(al2, bl2)) | 0;6682 -1 mid = (mid + Math.imul(al2, bh2)) | 0;6683 -1 mid = (mid + Math.imul(ah2, bl2)) | 0;6684 -1 hi = (hi + Math.imul(ah2, bh2)) | 0;6685 -1 lo = (lo + Math.imul(al1, bl3)) | 0;6686 -1 mid = (mid + Math.imul(al1, bh3)) | 0;6687 -1 mid = (mid + Math.imul(ah1, bl3)) | 0;6688 -1 hi = (hi + Math.imul(ah1, bh3)) | 0;6689 -1 lo = (lo + Math.imul(al0, bl4)) | 0;6690 -1 mid = (mid + Math.imul(al0, bh4)) | 0;6691 -1 mid = (mid + Math.imul(ah0, bl4)) | 0;6692 -1 hi = (hi + Math.imul(ah0, bh4)) | 0;6693 -1 var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6694 -1 c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;6695 -1 w4 &= 0x3ffffff;6696 -1 /* k = 5 */6697 -1 lo = Math.imul(al5, bl0);6698 -1 mid = Math.imul(al5, bh0);6699 -1 mid = (mid + Math.imul(ah5, bl0)) | 0;6700 -1 hi = Math.imul(ah5, bh0);6701 -1 lo = (lo + Math.imul(al4, bl1)) | 0;6702 -1 mid = (mid + Math.imul(al4, bh1)) | 0;6703 -1 mid = (mid + Math.imul(ah4, bl1)) | 0;6704 -1 hi = (hi + Math.imul(ah4, bh1)) | 0;6705 -1 lo = (lo + Math.imul(al3, bl2)) | 0;6706 -1 mid = (mid + Math.imul(al3, bh2)) | 0;6707 -1 mid = (mid + Math.imul(ah3, bl2)) | 0;6708 -1 hi = (hi + Math.imul(ah3, bh2)) | 0;6709 -1 lo = (lo + Math.imul(al2, bl3)) | 0;6710 -1 mid = (mid + Math.imul(al2, bh3)) | 0;6711 -1 mid = (mid + Math.imul(ah2, bl3)) | 0;6712 -1 hi = (hi + Math.imul(ah2, bh3)) | 0;6713 -1 lo = (lo + Math.imul(al1, bl4)) | 0;6714 -1 mid = (mid + Math.imul(al1, bh4)) | 0;6715 -1 mid = (mid + Math.imul(ah1, bl4)) | 0;6716 -1 hi = (hi + Math.imul(ah1, bh4)) | 0;6717 -1 lo = (lo + Math.imul(al0, bl5)) | 0;6718 -1 mid = (mid + Math.imul(al0, bh5)) | 0;6719 -1 mid = (mid + Math.imul(ah0, bl5)) | 0;6720 -1 hi = (hi + Math.imul(ah0, bh5)) | 0;6721 -1 var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6722 -1 c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;6723 -1 w5 &= 0x3ffffff;6724 -1 /* k = 6 */6725 -1 lo = Math.imul(al6, bl0);6726 -1 mid = Math.imul(al6, bh0);6727 -1 mid = (mid + Math.imul(ah6, bl0)) | 0;6728 -1 hi = Math.imul(ah6, bh0);6729 -1 lo = (lo + Math.imul(al5, bl1)) | 0;6730 -1 mid = (mid + Math.imul(al5, bh1)) | 0;6731 -1 mid = (mid + Math.imul(ah5, bl1)) | 0;6732 -1 hi = (hi + Math.imul(ah5, bh1)) | 0;6733 -1 lo = (lo + Math.imul(al4, bl2)) | 0;6734 -1 mid = (mid + Math.imul(al4, bh2)) | 0;6735 -1 mid = (mid + Math.imul(ah4, bl2)) | 0;6736 -1 hi = (hi + Math.imul(ah4, bh2)) | 0;6737 -1 lo = (lo + Math.imul(al3, bl3)) | 0;6738 -1 mid = (mid + Math.imul(al3, bh3)) | 0;6739 -1 mid = (mid + Math.imul(ah3, bl3)) | 0;6740 -1 hi = (hi + Math.imul(ah3, bh3)) | 0;6741 -1 lo = (lo + Math.imul(al2, bl4)) | 0;6742 -1 mid = (mid + Math.imul(al2, bh4)) | 0;6743 -1 mid = (mid + Math.imul(ah2, bl4)) | 0;6744 -1 hi = (hi + Math.imul(ah2, bh4)) | 0;6745 -1 lo = (lo + Math.imul(al1, bl5)) | 0;6746 -1 mid = (mid + Math.imul(al1, bh5)) | 0;6747 -1 mid = (mid + Math.imul(ah1, bl5)) | 0;6748 -1 hi = (hi + Math.imul(ah1, bh5)) | 0;6749 -1 lo = (lo + Math.imul(al0, bl6)) | 0;6750 -1 mid = (mid + Math.imul(al0, bh6)) | 0;6751 -1 mid = (mid + Math.imul(ah0, bl6)) | 0;6752 -1 hi = (hi + Math.imul(ah0, bh6)) | 0;6753 -1 var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6754 -1 c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;6755 -1 w6 &= 0x3ffffff;6756 -1 /* k = 7 */6757 -1 lo = Math.imul(al7, bl0);6758 -1 mid = Math.imul(al7, bh0);6759 -1 mid = (mid + Math.imul(ah7, bl0)) | 0;6760 -1 hi = Math.imul(ah7, bh0);6761 -1 lo = (lo + Math.imul(al6, bl1)) | 0;6762 -1 mid = (mid + Math.imul(al6, bh1)) | 0;6763 -1 mid = (mid + Math.imul(ah6, bl1)) | 0;6764 -1 hi = (hi + Math.imul(ah6, bh1)) | 0;6765 -1 lo = (lo + Math.imul(al5, bl2)) | 0;6766 -1 mid = (mid + Math.imul(al5, bh2)) | 0;6767 -1 mid = (mid + Math.imul(ah5, bl2)) | 0;6768 -1 hi = (hi + Math.imul(ah5, bh2)) | 0;6769 -1 lo = (lo + Math.imul(al4, bl3)) | 0;6770 -1 mid = (mid + Math.imul(al4, bh3)) | 0;6771 -1 mid = (mid + Math.imul(ah4, bl3)) | 0;6772 -1 hi = (hi + Math.imul(ah4, bh3)) | 0;6773 -1 lo = (lo + Math.imul(al3, bl4)) | 0;6774 -1 mid = (mid + Math.imul(al3, bh4)) | 0;6775 -1 mid = (mid + Math.imul(ah3, bl4)) | 0;6776 -1 hi = (hi + Math.imul(ah3, bh4)) | 0;6777 -1 lo = (lo + Math.imul(al2, bl5)) | 0;6778 -1 mid = (mid + Math.imul(al2, bh5)) | 0;6779 -1 mid = (mid + Math.imul(ah2, bl5)) | 0;6780 -1 hi = (hi + Math.imul(ah2, bh5)) | 0;6781 -1 lo = (lo + Math.imul(al1, bl6)) | 0;6782 -1 mid = (mid + Math.imul(al1, bh6)) | 0;6783 -1 mid = (mid + Math.imul(ah1, bl6)) | 0;6784 -1 hi = (hi + Math.imul(ah1, bh6)) | 0;6785 -1 lo = (lo + Math.imul(al0, bl7)) | 0;6786 -1 mid = (mid + Math.imul(al0, bh7)) | 0;6787 -1 mid = (mid + Math.imul(ah0, bl7)) | 0;6788 -1 hi = (hi + Math.imul(ah0, bh7)) | 0;6789 -1 var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6790 -1 c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;6791 -1 w7 &= 0x3ffffff;6792 -1 /* k = 8 */6793 -1 lo = Math.imul(al8, bl0);6794 -1 mid = Math.imul(al8, bh0);6795 -1 mid = (mid + Math.imul(ah8, bl0)) | 0;6796 -1 hi = Math.imul(ah8, bh0);6797 -1 lo = (lo + Math.imul(al7, bl1)) | 0;6798 -1 mid = (mid + Math.imul(al7, bh1)) | 0;6799 -1 mid = (mid + Math.imul(ah7, bl1)) | 0;6800 -1 hi = (hi + Math.imul(ah7, bh1)) | 0;6801 -1 lo = (lo + Math.imul(al6, bl2)) | 0;6802 -1 mid = (mid + Math.imul(al6, bh2)) | 0;6803 -1 mid = (mid + Math.imul(ah6, bl2)) | 0;6804 -1 hi = (hi + Math.imul(ah6, bh2)) | 0;6805 -1 lo = (lo + Math.imul(al5, bl3)) | 0;6806 -1 mid = (mid + Math.imul(al5, bh3)) | 0;6807 -1 mid = (mid + Math.imul(ah5, bl3)) | 0;6808 -1 hi = (hi + Math.imul(ah5, bh3)) | 0;6809 -1 lo = (lo + Math.imul(al4, bl4)) | 0;6810 -1 mid = (mid + Math.imul(al4, bh4)) | 0;6811 -1 mid = (mid + Math.imul(ah4, bl4)) | 0;6812 -1 hi = (hi + Math.imul(ah4, bh4)) | 0;6813 -1 lo = (lo + Math.imul(al3, bl5)) | 0;6814 -1 mid = (mid + Math.imul(al3, bh5)) | 0;6815 -1 mid = (mid + Math.imul(ah3, bl5)) | 0;6816 -1 hi = (hi + Math.imul(ah3, bh5)) | 0;6817 -1 lo = (lo + Math.imul(al2, bl6)) | 0;6818 -1 mid = (mid + Math.imul(al2, bh6)) | 0;6819 -1 mid = (mid + Math.imul(ah2, bl6)) | 0;6820 -1 hi = (hi + Math.imul(ah2, bh6)) | 0;6821 -1 lo = (lo + Math.imul(al1, bl7)) | 0;6822 -1 mid = (mid + Math.imul(al1, bh7)) | 0;6823 -1 mid = (mid + Math.imul(ah1, bl7)) | 0;6824 -1 hi = (hi + Math.imul(ah1, bh7)) | 0;6825 -1 lo = (lo + Math.imul(al0, bl8)) | 0;6826 -1 mid = (mid + Math.imul(al0, bh8)) | 0;6827 -1 mid = (mid + Math.imul(ah0, bl8)) | 0;6828 -1 hi = (hi + Math.imul(ah0, bh8)) | 0;6829 -1 var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6830 -1 c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;6831 -1 w8 &= 0x3ffffff;6832 -1 /* k = 9 */6833 -1 lo = Math.imul(al9, bl0);6834 -1 mid = Math.imul(al9, bh0);6835 -1 mid = (mid + Math.imul(ah9, bl0)) | 0;6836 -1 hi = Math.imul(ah9, bh0);6837 -1 lo = (lo + Math.imul(al8, bl1)) | 0;6838 -1 mid = (mid + Math.imul(al8, bh1)) | 0;6839 -1 mid = (mid + Math.imul(ah8, bl1)) | 0;6840 -1 hi = (hi + Math.imul(ah8, bh1)) | 0;6841 -1 lo = (lo + Math.imul(al7, bl2)) | 0;6842 -1 mid = (mid + Math.imul(al7, bh2)) | 0;6843 -1 mid = (mid + Math.imul(ah7, bl2)) | 0;6844 -1 hi = (hi + Math.imul(ah7, bh2)) | 0;6845 -1 lo = (lo + Math.imul(al6, bl3)) | 0;6846 -1 mid = (mid + Math.imul(al6, bh3)) | 0;6847 -1 mid = (mid + Math.imul(ah6, bl3)) | 0;6848 -1 hi = (hi + Math.imul(ah6, bh3)) | 0;6849 -1 lo = (lo + Math.imul(al5, bl4)) | 0;6850 -1 mid = (mid + Math.imul(al5, bh4)) | 0;6851 -1 mid = (mid + Math.imul(ah5, bl4)) | 0;6852 -1 hi = (hi + Math.imul(ah5, bh4)) | 0;6853 -1 lo = (lo + Math.imul(al4, bl5)) | 0;6854 -1 mid = (mid + Math.imul(al4, bh5)) | 0;6855 -1 mid = (mid + Math.imul(ah4, bl5)) | 0;6856 -1 hi = (hi + Math.imul(ah4, bh5)) | 0;6857 -1 lo = (lo + Math.imul(al3, bl6)) | 0;6858 -1 mid = (mid + Math.imul(al3, bh6)) | 0;6859 -1 mid = (mid + Math.imul(ah3, bl6)) | 0;6860 -1 hi = (hi + Math.imul(ah3, bh6)) | 0;6861 -1 lo = (lo + Math.imul(al2, bl7)) | 0;6862 -1 mid = (mid + Math.imul(al2, bh7)) | 0;6863 -1 mid = (mid + Math.imul(ah2, bl7)) | 0;6864 -1 hi = (hi + Math.imul(ah2, bh7)) | 0;6865 -1 lo = (lo + Math.imul(al1, bl8)) | 0;6866 -1 mid = (mid + Math.imul(al1, bh8)) | 0;6867 -1 mid = (mid + Math.imul(ah1, bl8)) | 0;6868 -1 hi = (hi + Math.imul(ah1, bh8)) | 0;6869 -1 lo = (lo + Math.imul(al0, bl9)) | 0;6870 -1 mid = (mid + Math.imul(al0, bh9)) | 0;6871 -1 mid = (mid + Math.imul(ah0, bl9)) | 0;6872 -1 hi = (hi + Math.imul(ah0, bh9)) | 0;6873 -1 var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6874 -1 c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;6875 -1 w9 &= 0x3ffffff;6876 -1 /* k = 10 */6877 -1 lo = Math.imul(al9, bl1);6878 -1 mid = Math.imul(al9, bh1);6879 -1 mid = (mid + Math.imul(ah9, bl1)) | 0;6880 -1 hi = Math.imul(ah9, bh1);6881 -1 lo = (lo + Math.imul(al8, bl2)) | 0;6882 -1 mid = (mid + Math.imul(al8, bh2)) | 0;6883 -1 mid = (mid + Math.imul(ah8, bl2)) | 0;6884 -1 hi = (hi + Math.imul(ah8, bh2)) | 0;6885 -1 lo = (lo + Math.imul(al7, bl3)) | 0;6886 -1 mid = (mid + Math.imul(al7, bh3)) | 0;6887 -1 mid = (mid + Math.imul(ah7, bl3)) | 0;6888 -1 hi = (hi + Math.imul(ah7, bh3)) | 0;6889 -1 lo = (lo + Math.imul(al6, bl4)) | 0;6890 -1 mid = (mid + Math.imul(al6, bh4)) | 0;6891 -1 mid = (mid + Math.imul(ah6, bl4)) | 0;6892 -1 hi = (hi + Math.imul(ah6, bh4)) | 0;6893 -1 lo = (lo + Math.imul(al5, bl5)) | 0;6894 -1 mid = (mid + Math.imul(al5, bh5)) | 0;6895 -1 mid = (mid + Math.imul(ah5, bl5)) | 0;6896 -1 hi = (hi + Math.imul(ah5, bh5)) | 0;6897 -1 lo = (lo + Math.imul(al4, bl6)) | 0;6898 -1 mid = (mid + Math.imul(al4, bh6)) | 0;6899 -1 mid = (mid + Math.imul(ah4, bl6)) | 0;6900 -1 hi = (hi + Math.imul(ah4, bh6)) | 0;6901 -1 lo = (lo + Math.imul(al3, bl7)) | 0;6902 -1 mid = (mid + Math.imul(al3, bh7)) | 0;6903 -1 mid = (mid + Math.imul(ah3, bl7)) | 0;6904 -1 hi = (hi + Math.imul(ah3, bh7)) | 0;6905 -1 lo = (lo + Math.imul(al2, bl8)) | 0;6906 -1 mid = (mid + Math.imul(al2, bh8)) | 0;6907 -1 mid = (mid + Math.imul(ah2, bl8)) | 0;6908 -1 hi = (hi + Math.imul(ah2, bh8)) | 0;6909 -1 lo = (lo + Math.imul(al1, bl9)) | 0;6910 -1 mid = (mid + Math.imul(al1, bh9)) | 0;6911 -1 mid = (mid + Math.imul(ah1, bl9)) | 0;6912 -1 hi = (hi + Math.imul(ah1, bh9)) | 0;6913 -1 var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6914 -1 c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;6915 -1 w10 &= 0x3ffffff;6916 -1 /* k = 11 */6917 -1 lo = Math.imul(al9, bl2);6918 -1 mid = Math.imul(al9, bh2);6919 -1 mid = (mid + Math.imul(ah9, bl2)) | 0;6920 -1 hi = Math.imul(ah9, bh2);6921 -1 lo = (lo + Math.imul(al8, bl3)) | 0;6922 -1 mid = (mid + Math.imul(al8, bh3)) | 0;6923 -1 mid = (mid + Math.imul(ah8, bl3)) | 0;6924 -1 hi = (hi + Math.imul(ah8, bh3)) | 0;6925 -1 lo = (lo + Math.imul(al7, bl4)) | 0;6926 -1 mid = (mid + Math.imul(al7, bh4)) | 0;6927 -1 mid = (mid + Math.imul(ah7, bl4)) | 0;6928 -1 hi = (hi + Math.imul(ah7, bh4)) | 0;6929 -1 lo = (lo + Math.imul(al6, bl5)) | 0;6930 -1 mid = (mid + Math.imul(al6, bh5)) | 0;6931 -1 mid = (mid + Math.imul(ah6, bl5)) | 0;6932 -1 hi = (hi + Math.imul(ah6, bh5)) | 0;6933 -1 lo = (lo + Math.imul(al5, bl6)) | 0;6934 -1 mid = (mid + Math.imul(al5, bh6)) | 0;6935 -1 mid = (mid + Math.imul(ah5, bl6)) | 0;6936 -1 hi = (hi + Math.imul(ah5, bh6)) | 0;6937 -1 lo = (lo + Math.imul(al4, bl7)) | 0;6938 -1 mid = (mid + Math.imul(al4, bh7)) | 0;6939 -1 mid = (mid + Math.imul(ah4, bl7)) | 0;6940 -1 hi = (hi + Math.imul(ah4, bh7)) | 0;6941 -1 lo = (lo + Math.imul(al3, bl8)) | 0;6942 -1 mid = (mid + Math.imul(al3, bh8)) | 0;6943 -1 mid = (mid + Math.imul(ah3, bl8)) | 0;6944 -1 hi = (hi + Math.imul(ah3, bh8)) | 0;6945 -1 lo = (lo + Math.imul(al2, bl9)) | 0;6946 -1 mid = (mid + Math.imul(al2, bh9)) | 0;6947 -1 mid = (mid + Math.imul(ah2, bl9)) | 0;6948 -1 hi = (hi + Math.imul(ah2, bh9)) | 0;6949 -1 var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6950 -1 c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;6951 -1 w11 &= 0x3ffffff;6952 -1 /* k = 12 */6953 -1 lo = Math.imul(al9, bl3);6954 -1 mid = Math.imul(al9, bh3);6955 -1 mid = (mid + Math.imul(ah9, bl3)) | 0;6956 -1 hi = Math.imul(ah9, bh3);6957 -1 lo = (lo + Math.imul(al8, bl4)) | 0;6958 -1 mid = (mid + Math.imul(al8, bh4)) | 0;6959 -1 mid = (mid + Math.imul(ah8, bl4)) | 0;6960 -1 hi = (hi + Math.imul(ah8, bh4)) | 0;6961 -1 lo = (lo + Math.imul(al7, bl5)) | 0;6962 -1 mid = (mid + Math.imul(al7, bh5)) | 0;6963 -1 mid = (mid + Math.imul(ah7, bl5)) | 0;6964 -1 hi = (hi + Math.imul(ah7, bh5)) | 0;6965 -1 lo = (lo + Math.imul(al6, bl6)) | 0;6966 -1 mid = (mid + Math.imul(al6, bh6)) | 0;6967 -1 mid = (mid + Math.imul(ah6, bl6)) | 0;6968 -1 hi = (hi + Math.imul(ah6, bh6)) | 0;6969 -1 lo = (lo + Math.imul(al5, bl7)) | 0;6970 -1 mid = (mid + Math.imul(al5, bh7)) | 0;6971 -1 mid = (mid + Math.imul(ah5, bl7)) | 0;6972 -1 hi = (hi + Math.imul(ah5, bh7)) | 0;6973 -1 lo = (lo + Math.imul(al4, bl8)) | 0;6974 -1 mid = (mid + Math.imul(al4, bh8)) | 0;6975 -1 mid = (mid + Math.imul(ah4, bl8)) | 0;6976 -1 hi = (hi + Math.imul(ah4, bh8)) | 0;6977 -1 lo = (lo + Math.imul(al3, bl9)) | 0;6978 -1 mid = (mid + Math.imul(al3, bh9)) | 0;6979 -1 mid = (mid + Math.imul(ah3, bl9)) | 0;6980 -1 hi = (hi + Math.imul(ah3, bh9)) | 0;6981 -1 var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;6982 -1 c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;6983 -1 w12 &= 0x3ffffff;6984 -1 /* k = 13 */6985 -1 lo = Math.imul(al9, bl4);6986 -1 mid = Math.imul(al9, bh4);6987 -1 mid = (mid + Math.imul(ah9, bl4)) | 0;6988 -1 hi = Math.imul(ah9, bh4);6989 -1 lo = (lo + Math.imul(al8, bl5)) | 0;6990 -1 mid = (mid + Math.imul(al8, bh5)) | 0;6991 -1 mid = (mid + Math.imul(ah8, bl5)) | 0;6992 -1 hi = (hi + Math.imul(ah8, bh5)) | 0;6993 -1 lo = (lo + Math.imul(al7, bl6)) | 0;6994 -1 mid = (mid + Math.imul(al7, bh6)) | 0;6995 -1 mid = (mid + Math.imul(ah7, bl6)) | 0;6996 -1 hi = (hi + Math.imul(ah7, bh6)) | 0;6997 -1 lo = (lo + Math.imul(al6, bl7)) | 0;6998 -1 mid = (mid + Math.imul(al6, bh7)) | 0;6999 -1 mid = (mid + Math.imul(ah6, bl7)) | 0;7000 -1 hi = (hi + Math.imul(ah6, bh7)) | 0;7001 -1 lo = (lo + Math.imul(al5, bl8)) | 0;7002 -1 mid = (mid + Math.imul(al5, bh8)) | 0;7003 -1 mid = (mid + Math.imul(ah5, bl8)) | 0;7004 -1 hi = (hi + Math.imul(ah5, bh8)) | 0;7005 -1 lo = (lo + Math.imul(al4, bl9)) | 0;7006 -1 mid = (mid + Math.imul(al4, bh9)) | 0;7007 -1 mid = (mid + Math.imul(ah4, bl9)) | 0;7008 -1 hi = (hi + Math.imul(ah4, bh9)) | 0;7009 -1 var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;7010 -1 c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;7011 -1 w13 &= 0x3ffffff;7012 -1 /* k = 14 */7013 -1 lo = Math.imul(al9, bl5);7014 -1 mid = Math.imul(al9, bh5);7015 -1 mid = (mid + Math.imul(ah9, bl5)) | 0;7016 -1 hi = Math.imul(ah9, bh5);7017 -1 lo = (lo + Math.imul(al8, bl6)) | 0;7018 -1 mid = (mid + Math.imul(al8, bh6)) | 0;7019 -1 mid = (mid + Math.imul(ah8, bl6)) | 0;7020 -1 hi = (hi + Math.imul(ah8, bh6)) | 0;7021 -1 lo = (lo + Math.imul(al7, bl7)) | 0;7022 -1 mid = (mid + Math.imul(al7, bh7)) | 0;7023 -1 mid = (mid + Math.imul(ah7, bl7)) | 0;7024 -1 hi = (hi + Math.imul(ah7, bh7)) | 0;7025 -1 lo = (lo + Math.imul(al6, bl8)) | 0;7026 -1 mid = (mid + Math.imul(al6, bh8)) | 0;7027 -1 mid = (mid + Math.imul(ah6, bl8)) | 0;7028 -1 hi = (hi + Math.imul(ah6, bh8)) | 0;7029 -1 lo = (lo + Math.imul(al5, bl9)) | 0;7030 -1 mid = (mid + Math.imul(al5, bh9)) | 0;7031 -1 mid = (mid + Math.imul(ah5, bl9)) | 0;7032 -1 hi = (hi + Math.imul(ah5, bh9)) | 0;7033 -1 var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;7034 -1 c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;7035 -1 w14 &= 0x3ffffff;7036 -1 /* k = 15 */7037 -1 lo = Math.imul(al9, bl6);7038 -1 mid = Math.imul(al9, bh6);7039 -1 mid = (mid + Math.imul(ah9, bl6)) | 0;7040 -1 hi = Math.imul(ah9, bh6);7041 -1 lo = (lo + Math.imul(al8, bl7)) | 0;7042 -1 mid = (mid + Math.imul(al8, bh7)) | 0;7043 -1 mid = (mid + Math.imul(ah8, bl7)) | 0;7044 -1 hi = (hi + Math.imul(ah8, bh7)) | 0;7045 -1 lo = (lo + Math.imul(al7, bl8)) | 0;7046 -1 mid = (mid + Math.imul(al7, bh8)) | 0;7047 -1 mid = (mid + Math.imul(ah7, bl8)) | 0;7048 -1 hi = (hi + Math.imul(ah7, bh8)) | 0;7049 -1 lo = (lo + Math.imul(al6, bl9)) | 0;7050 -1 mid = (mid + Math.imul(al6, bh9)) | 0;7051 -1 mid = (mid + Math.imul(ah6, bl9)) | 0;7052 -1 hi = (hi + Math.imul(ah6, bh9)) | 0;7053 -1 var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;7054 -1 c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;7055 -1 w15 &= 0x3ffffff;7056 -1 /* k = 16 */7057 -1 lo = Math.imul(al9, bl7);7058 -1 mid = Math.imul(al9, bh7);7059 -1 mid = (mid + Math.imul(ah9, bl7)) | 0;7060 -1 hi = Math.imul(ah9, bh7);7061 -1 lo = (lo + Math.imul(al8, bl8)) | 0;7062 -1 mid = (mid + Math.imul(al8, bh8)) | 0;7063 -1 mid = (mid + Math.imul(ah8, bl8)) | 0;7064 -1 hi = (hi + Math.imul(ah8, bh8)) | 0;7065 -1 lo = (lo + Math.imul(al7, bl9)) | 0;7066 -1 mid = (mid + Math.imul(al7, bh9)) | 0;7067 -1 mid = (mid + Math.imul(ah7, bl9)) | 0;7068 -1 hi = (hi + Math.imul(ah7, bh9)) | 0;7069 -1 var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;7070 -1 c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;7071 -1 w16 &= 0x3ffffff;7072 -1 /* k = 17 */7073 -1 lo = Math.imul(al9, bl8);7074 -1 mid = Math.imul(al9, bh8);7075 -1 mid = (mid + Math.imul(ah9, bl8)) | 0;7076 -1 hi = Math.imul(ah9, bh8);7077 -1 lo = (lo + Math.imul(al8, bl9)) | 0;7078 -1 mid = (mid + Math.imul(al8, bh9)) | 0;7079 -1 mid = (mid + Math.imul(ah8, bl9)) | 0;7080 -1 hi = (hi + Math.imul(ah8, bh9)) | 0;7081 -1 var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;7082 -1 c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;7083 -1 w17 &= 0x3ffffff;7084 -1 /* k = 18 */7085 -1 lo = Math.imul(al9, bl9);7086 -1 mid = Math.imul(al9, bh9);7087 -1 mid = (mid + Math.imul(ah9, bl9)) | 0;7088 -1 hi = Math.imul(ah9, bh9);7089 -1 var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;7090 -1 c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;7091 -1 w18 &= 0x3ffffff;7092 -1 o[0] = w0;7093 -1 o[1] = w1;7094 -1 o[2] = w2;7095 -1 o[3] = w3;7096 -1 o[4] = w4;7097 -1 o[5] = w5;7098 -1 o[6] = w6;7099 -1 o[7] = w7;7100 -1 o[8] = w8;7101 -1 o[9] = w9;7102 -1 o[10] = w10;7103 -1 o[11] = w11;7104 -1 o[12] = w12;7105 -1 o[13] = w13;7106 -1 o[14] = w14;7107 -1 o[15] = w15;7108 -1 o[16] = w16;7109 -1 o[17] = w17;7110 -1 o[18] = w18;7111 -1 if (c !== 0) {7112 -1 o[19] = c;7113 -1 out.length++;7114 -1 }7115 -1 return out;7116 -1 };7117 -17118 -1 // Polyfill comb7119 -1 if (!Math.imul) {7120 -1 comb10MulTo = smallMulTo;7121 -1 }7122 -17123 -1 function bigMulTo (self, num, out) {7124 -1 out.negative = num.negative ^ self.negative;7125 -1 out.length = self.length + num.length;7126 -17127 -1 var carry = 0;7128 -1 var hncarry = 0;7129 -1 for (var k = 0; k < out.length - 1; k++) {7130 -1 // Sum all words with the same `i + j = k` and accumulate `ncarry`,7131 -1 // note that ncarry could be >= 0x3ffffff7132 -1 var ncarry = hncarry;7133 -1 hncarry = 0;7134 -1 var rword = carry & 0x3ffffff;7135 -1 var maxJ = Math.min(k, num.length - 1);7136 -1 for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {7137 -1 var i = k - j;7138 -1 var a = self.words[i] | 0;7139 -1 var b = num.words[j] | 0;7140 -1 var r = a * b;7141 -17142 -1 var lo = r & 0x3ffffff;7143 -1 ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;7144 -1 lo = (lo + rword) | 0;7145 -1 rword = lo & 0x3ffffff;7146 -1 ncarry = (ncarry + (lo >>> 26)) | 0;7147 -17148 -1 hncarry += ncarry >>> 26;7149 -1 ncarry &= 0x3ffffff;7150 -1 }7151 -1 out.words[k] = rword;7152 -1 carry = ncarry;7153 -1 ncarry = hncarry;7154 -1 }7155 -1 if (carry !== 0) {7156 -1 out.words[k] = carry;7157 -1 } else {7158 -1 out.length--;7159 -1 }7160 -17161 -1 return out._strip();7162 -1 }7163 -17164 -1 function jumboMulTo (self, num, out) {7165 -1 // Temporary disable, see https://github.com/indutny/bn.js/issues/2117166 -1 // var fftm = new FFTM();7167 -1 // return fftm.mulp(self, num, out);7168 -1 return bigMulTo(self, num, out);7169 -1 }7170 -17171 -1 BN.prototype.mulTo = function mulTo (num, out) {7172 -1 var res;7173 -1 var len = this.length + num.length;7174 -1 if (this.length === 10 && num.length === 10) {7175 -1 res = comb10MulTo(this, num, out);7176 -1 } else if (len < 63) {7177 -1 res = smallMulTo(this, num, out);7178 -1 } else if (len < 1024) {7179 -1 res = bigMulTo(this, num, out);7180 -1 } else {7181 -1 res = jumboMulTo(this, num, out);7182 -1 }7183 -17184 -1 return res;7185 -1 };7186 -17187 -1 // Cooley-Tukey algorithm for FFT7188 -1 // slightly revisited to rely on looping instead of recursion7189 -17190 -1 function FFTM (x, y) {7191 -1 this.x = x;7192 -1 this.y = y;7193 -1 }7194 -17195 -1 FFTM.prototype.makeRBT = function makeRBT (N) {7196 -1 var t = new Array(N);7197 -1 var l = BN.prototype._countBits(N) - 1;7198 -1 for (var i = 0; i < N; i++) {7199 -1 t[i] = this.revBin(i, l, N);7200 -1 }7201 -17202 -1 return t;7203 -1 };7204 -17205 -1 // Returns binary-reversed representation of `x`7206 -1 FFTM.prototype.revBin = function revBin (x, l, N) {7207 -1 if (x === 0 || x === N - 1) return x;7208 -17209 -1 var rb = 0;7210 -1 for (var i = 0; i < l; i++) {7211 -1 rb |= (x & 1) << (l - i - 1);7212 -1 x >>= 1;7213 -1 }7214 -17215 -1 return rb;7216 -1 };7217 -17218 -1 // Performs "tweedling" phase, therefore 'emulating'7219 -1 // behaviour of the recursive algorithm7220 -1 FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {7221 -1 for (var i = 0; i < N; i++) {7222 -1 rtws[i] = rws[rbt[i]];7223 -1 itws[i] = iws[rbt[i]];7224 -1 }7225 -1 };7226 -17227 -1 FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {7228 -1 this.permute(rbt, rws, iws, rtws, itws, N);7229 -17230 -1 for (var s = 1; s < N; s <<= 1) {7231 -1 var l = s << 1;7232 -17233 -1 var rtwdf = Math.cos(2 * Math.PI / l);7234 -1 var itwdf = Math.sin(2 * Math.PI / l);7235 -17236 -1 for (var p = 0; p < N; p += l) {7237 -1 var rtwdf_ = rtwdf;7238 -1 var itwdf_ = itwdf;7239 -17240 -1 for (var j = 0; j < s; j++) {7241 -1 var re = rtws[p + j];7242 -1 var ie = itws[p + j];7243 -17244 -1 var ro = rtws[p + j + s];7245 -1 var io = itws[p + j + s];7246 -17247 -1 var rx = rtwdf_ * ro - itwdf_ * io;7248 -17249 -1 io = rtwdf_ * io + itwdf_ * ro;7250 -1 ro = rx;7251 -17252 -1 rtws[p + j] = re + ro;7253 -1 itws[p + j] = ie + io;7254 -17255 -1 rtws[p + j + s] = re - ro;7256 -1 itws[p + j + s] = ie - io;7257 -17258 -1 /* jshint maxdepth : false */7259 -1 if (j !== l) {7260 -1 rx = rtwdf * rtwdf_ - itwdf * itwdf_;7261 -17262 -1 itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;7263 -1 rtwdf_ = rx;7264 -1 }7265 -1 }7266 -1 }7267 -1 }7268 -1 };7269 -17270 -1 FFTM.prototype.guessLen13b = function guessLen13b (n, m) {7271 -1 var N = Math.max(m, n) | 1;7272 -1 var odd = N & 1;7273 -1 var i = 0;7274 -1 for (N = N / 2 | 0; N; N = N >>> 1) {7275 -1 i++;7276 -1 }7277 -17278 -1 return 1 << i + 1 + odd;7279 -1 };7280 -17281 -1 FFTM.prototype.conjugate = function conjugate (rws, iws, N) {7282 -1 if (N <= 1) return;7283 -17284 -1 for (var i = 0; i < N / 2; i++) {7285 -1 var t = rws[i];7286 -17287 -1 rws[i] = rws[N - i - 1];7288 -1 rws[N - i - 1] = t;7289 -17290 -1 t = iws[i];7291 -17292 -1 iws[i] = -iws[N - i - 1];7293 -1 iws[N - i - 1] = -t;7294 -1 }7295 -1 };7296 -17297 -1 FFTM.prototype.normalize13b = function normalize13b (ws, N) {7298 -1 var carry = 0;7299 -1 for (var i = 0; i < N / 2; i++) {7300 -1 var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +7301 -1 Math.round(ws[2 * i] / N) +7302 -1 carry;7303 -17304 -1 ws[i] = w & 0x3ffffff;7305 -17306 -1 if (w < 0x4000000) {7307 -1 carry = 0;7308 -1 } else {7309 -1 carry = w / 0x4000000 | 0;7310 -1 }7311 -1 }7312 -17313 -1 return ws;7314 -1 };7315 -17316 -1 FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {7317 -1 var carry = 0;7318 -1 for (var i = 0; i < len; i++) {7319 -1 carry = carry + (ws[i] | 0);7320 -17321 -1 rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;7322 -1 rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;7323 -1 }7324 -17325 -1 // Pad with zeroes7326 -1 for (i = 2 * len; i < N; ++i) {7327 -1 rws[i] = 0;7328 -1 }7329 -17330 -1 assert(carry === 0);7331 -1 assert((carry & ~0x1fff) === 0);7332 -1 };7333 -17334 -1 FFTM.prototype.stub = function stub (N) {7335 -1 var ph = new Array(N);7336 -1 for (var i = 0; i < N; i++) {7337 -1 ph[i] = 0;7338 -1 }7339 -17340 -1 return ph;7341 -1 };7342 -17343 -1 FFTM.prototype.mulp = function mulp (x, y, out) {7344 -1 var N = 2 * this.guessLen13b(x.length, y.length);7345 -17346 -1 var rbt = this.makeRBT(N);7347 -17348 -1 var _ = this.stub(N);7349 -17350 -1 var rws = new Array(N);7351 -1 var rwst = new Array(N);7352 -1 var iwst = new Array(N);7353 -17354 -1 var nrws = new Array(N);7355 -1 var nrwst = new Array(N);7356 -1 var niwst = new Array(N);7357 -17358 -1 var rmws = out.words;7359 -1 rmws.length = N;7360 -17361 -1 this.convert13b(x.words, x.length, rws, N);7362 -1 this.convert13b(y.words, y.length, nrws, N);7363 -17364 -1 this.transform(rws, _, rwst, iwst, N, rbt);7365 -1 this.transform(nrws, _, nrwst, niwst, N, rbt);7366 -17367 -1 for (var i = 0; i < N; i++) {7368 -1 var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];7369 -1 iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];7370 -1 rwst[i] = rx;7371 -1 }7372 -17373 -1 this.conjugate(rwst, iwst, N);7374 -1 this.transform(rwst, iwst, rmws, _, N, rbt);7375 -1 this.conjugate(rmws, _, N);7376 -1 this.normalize13b(rmws, N);7377 -17378 -1 out.negative = x.negative ^ y.negative;7379 -1 out.length = x.length + y.length;7380 -1 return out._strip();7381 -1 };7382 -17383 -1 // Multiply `this` by `num`7384 -1 BN.prototype.mul = function mul (num) {7385 -1 var out = new BN(null);7386 -1 out.words = new Array(this.length + num.length);7387 -1 return this.mulTo(num, out);7388 -1 };7389 -17390 -1 // Multiply employing FFT7391 -1 BN.prototype.mulf = function mulf (num) {7392 -1 var out = new BN(null);7393 -1 out.words = new Array(this.length + num.length);7394 -1 return jumboMulTo(this, num, out);7395 -1 };7396 -17397 -1 // In-place Multiplication7398 -1 BN.prototype.imul = function imul (num) {7399 -1 return this.clone().mulTo(num, this);7400 -1 };7401 -17402 -1 BN.prototype.imuln = function imuln (num) {7403 -1 var isNegNum = num < 0;7404 -1 if (isNegNum) num = -num;7405 -17406 -1 assert(typeof num === 'number');7407 -1 assert(num < 0x4000000);7408 -17409 -1 // Carry7410 -1 var carry = 0;7411 -1 for (var i = 0; i < this.length; i++) {7412 -1 var w = (this.words[i] | 0) * num;7413 -1 var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);7414 -1 carry >>= 26;7415 -1 carry += (w / 0x4000000) | 0;7416 -1 // NOTE: lo is 27bit maximum7417 -1 carry += lo >>> 26;7418 -1 this.words[i] = lo & 0x3ffffff;7419 -1 }7420 -17421 -1 if (carry !== 0) {7422 -1 this.words[i] = carry;7423 -1 this.length++;7424 -1 }7425 -17426 -1 return isNegNum ? this.ineg() : this;7427 -1 };7428 -17429 -1 BN.prototype.muln = function muln (num) {7430 -1 return this.clone().imuln(num);7431 -1 };7432 -17433 -1 // `this` * `this`7434 -1 BN.prototype.sqr = function sqr () {7435 -1 return this.mul(this);7436 -1 };7437 -17438 -1 // `this` * `this` in-place7439 -1 BN.prototype.isqr = function isqr () {7440 -1 return this.imul(this.clone());7441 -1 };7442 -17443 -1 // Math.pow(`this`, `num`)7444 -1 BN.prototype.pow = function pow (num) {7445 -1 var w = toBitArray(num);7446 -1 if (w.length === 0) return new BN(1);7447 -17448 -1 // Skip leading zeroes7449 -1 var res = this;7450 -1 for (var i = 0; i < w.length; i++, res = res.sqr()) {7451 -1 if (w[i] !== 0) break;7452 -1 }7453 -17454 -1 if (++i < w.length) {7455 -1 for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {7456 -1 if (w[i] === 0) continue;7457 -17458 -1 res = res.mul(q);7459 -1 }7460 -1 }7461 -17462 -1 return res;7463 -1 };7464 -17465 -1 // Shift-left in-place7466 -1 BN.prototype.iushln = function iushln (bits) {7467 -1 assert(typeof bits === 'number' && bits >= 0);7468 -1 var r = bits % 26;7469 -1 var s = (bits - r) / 26;7470 -1 var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);7471 -1 var i;7472 -17473 -1 if (r !== 0) {7474 -1 var carry = 0;7475 -17476 -1 for (i = 0; i < this.length; i++) {7477 -1 var newCarry = this.words[i] & carryMask;7478 -1 var c = ((this.words[i] | 0) - newCarry) << r;7479 -1 this.words[i] = c | carry;7480 -1 carry = newCarry >>> (26 - r);7481 -1 }7482 -17483 -1 if (carry) {7484 -1 this.words[i] = carry;7485 -1 this.length++;7486 -1 }7487 -1 }7488 -17489 -1 if (s !== 0) {7490 -1 for (i = this.length - 1; i >= 0; i--) {7491 -1 this.words[i + s] = this.words[i];7492 -1 }7493 -17494 -1 for (i = 0; i < s; i++) {7495 -1 this.words[i] = 0;7496 -1 }7497 -17498 -1 this.length += s;7499 -1 }7500 -17501 -1 return this._strip();7502 -1 };7503 -17504 -1 BN.prototype.ishln = function ishln (bits) {7505 -1 // TODO(indutny): implement me7506 -1 assert(this.negative === 0);7507 -1 return this.iushln(bits);7508 -1 };7509 -17510 -1 // Shift-right in-place7511 -1 // NOTE: `hint` is a lowest bit before trailing zeroes7512 -1 // NOTE: if `extended` is present - it will be filled with destroyed bits7513 -1 BN.prototype.iushrn = function iushrn (bits, hint, extended) {7514 -1 assert(typeof bits === 'number' && bits >= 0);7515 -1 var h;7516 -1 if (hint) {7517 -1 h = (hint - (hint % 26)) / 26;7518 -1 } else {7519 -1 h = 0;7520 -1 }7521 -17522 -1 var r = bits % 26;7523 -1 var s = Math.min((bits - r) / 26, this.length);7524 -1 var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);7525 -1 var maskedWords = extended;7526 -17527 -1 h -= s;7528 -1 h = Math.max(0, h);7529 -17530 -1 // Extended mode, copy masked part7531 -1 if (maskedWords) {7532 -1 for (var i = 0; i < s; i++) {7533 -1 maskedWords.words[i] = this.words[i];7534 -1 }7535 -1 maskedWords.length = s;7536 -1 }7537 -17538 -1 if (s === 0) {7539 -1 // No-op, we should not move anything at all7540 -1 } else if (this.length > s) {7541 -1 this.length -= s;7542 -1 for (i = 0; i < this.length; i++) {7543 -1 this.words[i] = this.words[i + s];7544 -1 }7545 -1 } else {7546 -1 this.words[0] = 0;7547 -1 this.length = 1;7548 -1 }7549 -17550 -1 var carry = 0;7551 -1 for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {7552 -1 var word = this.words[i] | 0;7553 -1 this.words[i] = (carry << (26 - r)) | (word >>> r);7554 -1 carry = word & mask;7555 -1 }7556 -17557 -1 // Push carried bits as a mask7558 -1 if (maskedWords && carry !== 0) {7559 -1 maskedWords.words[maskedWords.length++] = carry;7560 -1 }7561 -17562 -1 if (this.length === 0) {7563 -1 this.words[0] = 0;7564 -1 this.length = 1;7565 -1 }7566 -17567 -1 return this._strip();7568 -1 };7569 -17570 -1 BN.prototype.ishrn = function ishrn (bits, hint, extended) {7571 -1 // TODO(indutny): implement me7572 -1 assert(this.negative === 0);7573 -1 return this.iushrn(bits, hint, extended);7574 -1 };7575 -17576 -1 // Shift-left7577 -1 BN.prototype.shln = function shln (bits) {7578 -1 return this.clone().ishln(bits);7579 -1 };7580 -17581 -1 BN.prototype.ushln = function ushln (bits) {7582 -1 return this.clone().iushln(bits);7583 -1 };7584 -17585 -1 // Shift-right7586 -1 BN.prototype.shrn = function shrn (bits) {7587 -1 return this.clone().ishrn(bits);7588 -1 };7589 -17590 -1 BN.prototype.ushrn = function ushrn (bits) {7591 -1 return this.clone().iushrn(bits);7592 -1 };7593 -17594 -1 // Test if n bit is set7595 -1 BN.prototype.testn = function testn (bit) {7596 -1 assert(typeof bit === 'number' && bit >= 0);7597 -1 var r = bit % 26;7598 -1 var s = (bit - r) / 26;7599 -1 var q = 1 << r;7600 -17601 -1 // Fast case: bit is much higher than all existing words7602 -1 if (this.length <= s) return false;7603 -17604 -1 // Check bit and return7605 -1 var w = this.words[s];7606 -17607 -1 return !!(w & q);7608 -1 };7609 -17610 -1 // Return only lowers bits of number (in-place)7611 -1 BN.prototype.imaskn = function imaskn (bits) {7612 -1 assert(typeof bits === 'number' && bits >= 0);7613 -1 var r = bits % 26;7614 -1 var s = (bits - r) / 26;7615 -17616 -1 assert(this.negative === 0, 'imaskn works only with positive numbers');7617 -17618 -1 if (this.length <= s) {7619 -1 return this;7620 -1 }7621 -17622 -1 if (r !== 0) {7623 -1 s++;7624 -1 }7625 -1 this.length = Math.min(s, this.length);7626 -17627 -1 if (r !== 0) {7628 -1 var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);7629 -1 this.words[this.length - 1] &= mask;7630 -1 }7631 -17632 -1 return this._strip();7633 -1 };7634 -17635 -1 // Return only lowers bits of number7636 -1 BN.prototype.maskn = function maskn (bits) {7637 -1 return this.clone().imaskn(bits);7638 -1 };7639 -17640 -1 // Add plain number `num` to `this`7641 -1 BN.prototype.iaddn = function iaddn (num) {7642 -1 assert(typeof num === 'number');7643 -1 assert(num < 0x4000000);7644 -1 if (num < 0) return this.isubn(-num);7645 -17646 -1 // Possible sign change7647 -1 if (this.negative !== 0) {7648 -1 if (this.length === 1 && (this.words[0] | 0) <= num) {7649 -1 this.words[0] = num - (this.words[0] | 0);7650 -1 this.negative = 0;7651 -1 return this;7652 -1 }7653 -17654 -1 this.negative = 0;7655 -1 this.isubn(num);7656 -1 this.negative = 1;7657 -1 return this;7658 -1 }7659 -17660 -1 // Add without checks7661 -1 return this._iaddn(num);7662 -1 };7663 -17664 -1 BN.prototype._iaddn = function _iaddn (num) {7665 -1 this.words[0] += num;7666 -17667 -1 // Carry7668 -1 for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {7669 -1 this.words[i] -= 0x4000000;7670 -1 if (i === this.length - 1) {7671 -1 this.words[i + 1] = 1;7672 -1 } else {7673 -1 this.words[i + 1]++;7674 -1 }7675 -1 }7676 -1 this.length = Math.max(this.length, i + 1);7677 -17678 -1 return this;7679 -1 };7680 -17681 -1 // Subtract plain number `num` from `this`7682 -1 BN.prototype.isubn = function isubn (num) {7683 -1 assert(typeof num === 'number');7684 -1 assert(num < 0x4000000);7685 -1 if (num < 0) return this.iaddn(-num);7686 -17687 -1 if (this.negative !== 0) {7688 -1 this.negative = 0;7689 -1 this.iaddn(num);7690 -1 this.negative = 1;7691 -1 return this;7692 -1 }7693 -17694 -1 this.words[0] -= num;7695 -17696 -1 if (this.length === 1 && this.words[0] < 0) {7697 -1 this.words[0] = -this.words[0];7698 -1 this.negative = 1;7699 -1 } else {7700 -1 // Carry7701 -1 for (var i = 0; i < this.length && this.words[i] < 0; i++) {7702 -1 this.words[i] += 0x4000000;7703 -1 this.words[i + 1] -= 1;7704 -1 }7705 -1 }7706 -17707 -1 return this._strip();7708 -1 };7709 -17710 -1 BN.prototype.addn = function addn (num) {7711 -1 return this.clone().iaddn(num);7712 -1 };7713 -17714 -1 BN.prototype.subn = function subn (num) {7715 -1 return this.clone().isubn(num);7716 -1 };7717 -17718 -1 BN.prototype.iabs = function iabs () {7719 -1 this.negative = 0;7720 -17721 -1 return this;7722 -1 };7723 -17724 -1 BN.prototype.abs = function abs () {7725 -1 return this.clone().iabs();7726 -1 };7727 -17728 -1 BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {7729 -1 var len = num.length + shift;7730 -1 var i;7731 -17732 -1 this._expand(len);7733 -17734 -1 var w;7735 -1 var carry = 0;7736 -1 for (i = 0; i < num.length; i++) {7737 -1 w = (this.words[i + shift] | 0) + carry;7738 -1 var right = (num.words[i] | 0) * mul;7739 -1 w -= right & 0x3ffffff;7740 -1 carry = (w >> 26) - ((right / 0x4000000) | 0);7741 -1 this.words[i + shift] = w & 0x3ffffff;7742 -1 }7743 -1 for (; i < this.length - shift; i++) {7744 -1 w = (this.words[i + shift] | 0) + carry;7745 -1 carry = w >> 26;7746 -1 this.words[i + shift] = w & 0x3ffffff;7747 -1 }7748 -17749 -1 if (carry === 0) return this._strip();7750 -17751 -1 // Subtraction overflow7752 -1 assert(carry === -1);7753 -1 carry = 0;7754 -1 for (i = 0; i < this.length; i++) {7755 -1 w = -(this.words[i] | 0) + carry;7756 -1 carry = w >> 26;7757 -1 this.words[i] = w & 0x3ffffff;7758 -1 }7759 -1 this.negative = 1;7760 -17761 -1 return this._strip();7762 -1 };7763 -17764 -1 BN.prototype._wordDiv = function _wordDiv (num, mode) {7765 -1 var shift = this.length - num.length;7766 -17767 -1 var a = this.clone();7768 -1 var b = num;7769 -17770 -1 // Normalize7771 -1 var bhi = b.words[b.length - 1] | 0;7772 -1 var bhiBits = this._countBits(bhi);7773 -1 shift = 26 - bhiBits;7774 -1 if (shift !== 0) {7775 -1 b = b.ushln(shift);7776 -1 a.iushln(shift);7777 -1 bhi = b.words[b.length - 1] | 0;7778 -1 }7779 -17780 -1 // Initialize quotient7781 -1 var m = a.length - b.length;7782 -1 var q;7783 -17784 -1 if (mode !== 'mod') {7785 -1 q = new BN(null);7786 -1 q.length = m + 1;7787 -1 q.words = new Array(q.length);7788 -1 for (var i = 0; i < q.length; i++) {7789 -1 q.words[i] = 0;7790 -1 }7791 -1 }7792 -17793 -1 var diff = a.clone()._ishlnsubmul(b, 1, m);7794 -1 if (diff.negative === 0) {7795 -1 a = diff;7796 -1 if (q) {7797 -1 q.words[m] = 1;7798 -1 }7799 -1 }7800 -17801 -1 for (var j = m - 1; j >= 0; j--) {7802 -1 var qj = (a.words[b.length + j] | 0) * 0x4000000 +7803 -1 (a.words[b.length + j - 1] | 0);7804 -17805 -1 // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max7806 -1 // (0x7ffffff)7807 -1 qj = Math.min((qj / bhi) | 0, 0x3ffffff);7808 -17809 -1 a._ishlnsubmul(b, qj, j);7810 -1 while (a.negative !== 0) {7811 -1 qj--;7812 -1 a.negative = 0;7813 -1 a._ishlnsubmul(b, 1, j);7814 -1 if (!a.isZero()) {7815 -1 a.negative ^= 1;7816 -1 }7817 -1 }7818 -1 if (q) {7819 -1 q.words[j] = qj;7820 -1 }7821 -1 }7822 -1 if (q) {7823 -1 q._strip();7824 -1 }7825 -1 a._strip();7826 -17827 -1 // Denormalize7828 -1 if (mode !== 'div' && shift !== 0) {7829 -1 a.iushrn(shift);7830 -1 }7831 -17832 -1 return {7833 -1 div: q || null,7834 -1 mod: a7835 -1 };7836 -1 };7837 -17838 -1 // NOTE: 1) `mode` can be set to `mod` to request mod only,7839 -1 // to `div` to request div only, or be absent to7840 -1 // request both div & mod7841 -1 // 2) `positive` is true if unsigned mod is requested7842 -1 BN.prototype.divmod = function divmod (num, mode, positive) {7843 -1 assert(!num.isZero());7844 -17845 -1 if (this.isZero()) {7846 -1 return {7847 -1 div: new BN(0),7848 -1 mod: new BN(0)7849 -1 };7850 -1 }7851 -17852 -1 var div, mod, res;7853 -1 if (this.negative !== 0 && num.negative === 0) {7854 -1 res = this.neg().divmod(num, mode);7855 -17856 -1 if (mode !== 'mod') {7857 -1 div = res.div.neg();7858 -1 }7859 -17860 -1 if (mode !== 'div') {7861 -1 mod = res.mod.neg();7862 -1 if (positive && mod.negative !== 0) {7863 -1 mod.iadd(num);7864 -1 }7865 -1 }7866 -17867 -1 return {7868 -1 div: div,7869 -1 mod: mod7870 -1 };7871 -1 }7872 -17873 -1 if (this.negative === 0 && num.negative !== 0) {7874 -1 res = this.divmod(num.neg(), mode);7875 -17876 -1 if (mode !== 'mod') {7877 -1 div = res.div.neg();7878 -1 }7879 -17880 -1 return {7881 -1 div: div,7882 -1 mod: res.mod7883 -1 };7884 -1 }7885 -17886 -1 if ((this.negative & num.negative) !== 0) {7887 -1 res = this.neg().divmod(num.neg(), mode);7888 -17889 -1 if (mode !== 'div') {7890 -1 mod = res.mod.neg();7891 -1 if (positive && mod.negative !== 0) {7892 -1 mod.isub(num);7893 -1 }7894 -1 }7895 -17896 -1 return {7897 -1 div: res.div,7898 -1 mod: mod7899 -1 };7900 -1 }7901 -17902 -1 // Both numbers are positive at this point7903 -17904 -1 // Strip both numbers to approximate shift value7905 -1 if (num.length > this.length || this.cmp(num) < 0) {7906 -1 return {7907 -1 div: new BN(0),7908 -1 mod: this7909 -1 };7910 -1 }7911 -17912 -1 // Very short reduction7913 -1 if (num.length === 1) {7914 -1 if (mode === 'div') {7915 -1 return {7916 -1 div: this.divn(num.words[0]),7917 -1 mod: null7918 -1 };7919 -1 }7920 -17921 -1 if (mode === 'mod') {7922 -1 return {7923 -1 div: null,7924 -1 mod: new BN(this.modrn(num.words[0]))7925 -1 };7926 -1 }7927 -17928 -1 return {7929 -1 div: this.divn(num.words[0]),7930 -1 mod: new BN(this.modrn(num.words[0]))7931 -1 };7932 -1 }7933 -17934 -1 return this._wordDiv(num, mode);7935 -1 };7936 -17937 -1 // Find `this` / `num`7938 -1 BN.prototype.div = function div (num) {7939 -1 return this.divmod(num, 'div', false).div;7940 -1 };7941 -17942 -1 // Find `this` % `num`7943 -1 BN.prototype.mod = function mod (num) {7944 -1 return this.divmod(num, 'mod', false).mod;7945 -1 };7946 -17947 -1 BN.prototype.umod = function umod (num) {7948 -1 return this.divmod(num, 'mod', true).mod;7949 -1 };7950 -17951 -1 // Find Round(`this` / `num`)7952 -1 BN.prototype.divRound = function divRound (num) {7953 -1 var dm = this.divmod(num);7954 -17955 -1 // Fast case - exact division7956 -1 if (dm.mod.isZero()) return dm.div;7957 -17958 -1 var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;7959 -17960 -1 var half = num.ushrn(1);7961 -1 var r2 = num.andln(1);7962 -1 var cmp = mod.cmp(half);7963 -17964 -1 // Round down7965 -1 if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div;7966 -17967 -1 // Round up7968 -1 return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);7969 -1 };7970 -17971 -1 BN.prototype.modrn = function modrn (num) {7972 -1 var isNegNum = num < 0;7973 -1 if (isNegNum) num = -num;7974 -17975 -1 assert(num <= 0x3ffffff);7976 -1 var p = (1 << 26) % num;7977 -17978 -1 var acc = 0;7979 -1 for (var i = this.length - 1; i >= 0; i--) {7980 -1 acc = (p * acc + (this.words[i] | 0)) % num;7981 -1 }7982 -17983 -1 return isNegNum ? -acc : acc;7984 -1 };7985 -17986 -1 // WARNING: DEPRECATED7987 -1 BN.prototype.modn = function modn (num) {7988 -1 return this.modrn(num);7989 -1 };7990 -17991 -1 // In-place division by number7992 -1 BN.prototype.idivn = function idivn (num) {7993 -1 var isNegNum = num < 0;7994 -1 if (isNegNum) num = -num;7995 -17996 -1 assert(num <= 0x3ffffff);7997 -17998 -1 var carry = 0;7999 -1 for (var i = this.length - 1; i >= 0; i--) {8000 -1 var w = (this.words[i] | 0) + carry * 0x4000000;8001 -1 this.words[i] = (w / num) | 0;8002 -1 carry = w % num;8003 -1 }8004 -18005 -1 this._strip();8006 -1 return isNegNum ? this.ineg() : this;8007 -1 };8008 -18009 -1 BN.prototype.divn = function divn (num) {8010 -1 return this.clone().idivn(num);8011 -1 };8012 -18013 -1 BN.prototype.egcd = function egcd (p) {8014 -1 assert(p.negative === 0);8015 -1 assert(!p.isZero());8016 -18017 -1 var x = this;8018 -1 var y = p.clone();8019 -18020 -1 if (x.negative !== 0) {8021 -1 x = x.umod(p);8022 -1 } else {8023 -1 x = x.clone();8024 -1 }8025 -18026 -1 // A * x + B * y = x8027 -1 var A = new BN(1);8028 -1 var B = new BN(0);8029 -18030 -1 // C * x + D * y = y8031 -1 var C = new BN(0);8032 -1 var D = new BN(1);8033 -18034 -1 var g = 0;8035 -18036 -1 while (x.isEven() && y.isEven()) {8037 -1 x.iushrn(1);8038 -1 y.iushrn(1);8039 -1 ++g;8040 -1 }8041 -18042 -1 var yp = y.clone();8043 -1 var xp = x.clone();8044 -18045 -1 while (!x.isZero()) {8046 -1 for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);8047 -1 if (i > 0) {8048 -1 x.iushrn(i);8049 -1 while (i-- > 0) {8050 -1 if (A.isOdd() || B.isOdd()) {8051 -1 A.iadd(yp);8052 -1 B.isub(xp);8053 -1 }8054 -18055 -1 A.iushrn(1);8056 -1 B.iushrn(1);8057 -1 }8058 -1 }8059 -18060 -1 for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);8061 -1 if (j > 0) {8062 -1 y.iushrn(j);8063 -1 while (j-- > 0) {8064 -1 if (C.isOdd() || D.isOdd()) {8065 -1 C.iadd(yp);8066 -1 D.isub(xp);8067 -1 }8068 -18069 -1 C.iushrn(1);8070 -1 D.iushrn(1);8071 -1 }8072 -1 }8073 -18074 -1 if (x.cmp(y) >= 0) {8075 -1 x.isub(y);8076 -1 A.isub(C);8077 -1 B.isub(D);8078 -1 } else {8079 -1 y.isub(x);8080 -1 C.isub(A);8081 -1 D.isub(B);8082 -1 }8083 -1 }8084 -18085 -1 return {8086 -1 a: C,8087 -1 b: D,8088 -1 gcd: y.iushln(g)8089 -1 };8090 -1 };8091 -18092 -1 // This is reduced incarnation of the binary EEA8093 -1 // above, designated to invert members of the8094 -1 // _prime_ fields F(p) at a maximal speed8095 -1 BN.prototype._invmp = function _invmp (p) {8096 -1 assert(p.negative === 0);8097 -1 assert(!p.isZero());8098 -18099 -1 var a = this;8100 -1 var b = p.clone();8101 -18102 -1 if (a.negative !== 0) {8103 -1 a = a.umod(p);8104 -1 } else {8105 -1 a = a.clone();8106 -1 }8107 -18108 -1 var x1 = new BN(1);8109 -1 var x2 = new BN(0);8110 -18111 -1 var delta = b.clone();8112 -18113 -1 while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {8114 -1 for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);8115 -1 if (i > 0) {8116 -1 a.iushrn(i);8117 -1 while (i-- > 0) {8118 -1 if (x1.isOdd()) {8119 -1 x1.iadd(delta);8120 -1 }8121 -18122 -1 x1.iushrn(1);8123 -1 }8124 -1 }8125 -18126 -1 for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);8127 -1 if (j > 0) {8128 -1 b.iushrn(j);8129 -1 while (j-- > 0) {8130 -1 if (x2.isOdd()) {8131 -1 x2.iadd(delta);8132 -1 }8133 -18134 -1 x2.iushrn(1);8135 -1 }8136 -1 }8137 -18138 -1 if (a.cmp(b) >= 0) {8139 -1 a.isub(b);8140 -1 x1.isub(x2);8141 -1 } else {8142 -1 b.isub(a);8143 -1 x2.isub(x1);8144 -1 }8145 -1 }8146 -18147 -1 var res;8148 -1 if (a.cmpn(1) === 0) {8149 -1 res = x1;8150 -1 } else {8151 -1 res = x2;8152 -1 }8153 -18154 -1 if (res.cmpn(0) < 0) {8155 -1 res.iadd(p);8156 -1 }8157 -18158 -1 return res;8159 -1 };8160 -18161 -1 BN.prototype.gcd = function gcd (num) {8162 -1 if (this.isZero()) return num.abs();8163 -1 if (num.isZero()) return this.abs();8164 -18165 -1 var a = this.clone();8166 -1 var b = num.clone();8167 -1 a.negative = 0;8168 -1 b.negative = 0;8169 -18170 -1 // Remove common factor of two8171 -1 for (var shift = 0; a.isEven() && b.isEven(); shift++) {8172 -1 a.iushrn(1);8173 -1 b.iushrn(1);8174 -1 }8175 -18176 -1 do {8177 -1 while (a.isEven()) {8178 -1 a.iushrn(1);8179 -1 }8180 -1 while (b.isEven()) {8181 -1 b.iushrn(1);8182 -1 }8183 -18184 -1 var r = a.cmp(b);8185 -1 if (r < 0) {8186 -1 // Swap `a` and `b` to make `a` always bigger than `b`8187 -1 var t = a;8188 -1 a = b;8189 -1 b = t;8190 -1 } else if (r === 0 || b.cmpn(1) === 0) {8191 -1 break;8192 -1 }8193 -18194 -1 a.isub(b);8195 -1 } while (true);8196 -18197 -1 return b.iushln(shift);8198 -1 };8199 -18200 -1 // Invert number in the field F(num)8201 -1 BN.prototype.invm = function invm (num) {8202 -1 return this.egcd(num).a.umod(num);8203 -1 };8204 -18205 -1 BN.prototype.isEven = function isEven () {8206 -1 return (this.words[0] & 1) === 0;8207 -1 };8208 -18209 -1 BN.prototype.isOdd = function isOdd () {8210 -1 return (this.words[0] & 1) === 1;8211 -1 };8212 -18213 -1 // And first word and num8214 -1 BN.prototype.andln = function andln (num) {8215 -1 return this.words[0] & num;8216 -1 };8217 -18218 -1 // Increment at the bit position in-line8219 -1 BN.prototype.bincn = function bincn (bit) {8220 -1 assert(typeof bit === 'number');8221 -1 var r = bit % 26;8222 -1 var s = (bit - r) / 26;8223 -1 var q = 1 << r;8224 -18225 -1 // Fast case: bit is much higher than all existing words8226 -1 if (this.length <= s) {8227 -1 this._expand(s + 1);8228 -1 this.words[s] |= q;8229 -1 return this;8230 -1 }8231 -18232 -1 // Add bit and propagate, if needed8233 -1 var carry = q;8234 -1 for (var i = s; carry !== 0 && i < this.length; i++) {8235 -1 var w = this.words[i] | 0;8236 -1 w += carry;8237 -1 carry = w >>> 26;8238 -1 w &= 0x3ffffff;8239 -1 this.words[i] = w;8240 -1 }8241 -1 if (carry !== 0) {8242 -1 this.words[i] = carry;8243 -1 this.length++;8244 -1 }8245 -1 return this;8246 -1 };8247 -18248 -1 BN.prototype.isZero = function isZero () {8249 -1 return this.length === 1 && this.words[0] === 0;8250 -1 };8251 -18252 -1 BN.prototype.cmpn = function cmpn (num) {8253 -1 var negative = num < 0;8254 -18255 -1 if (this.negative !== 0 && !negative) return -1;8256 -1 if (this.negative === 0 && negative) return 1;8257 -18258 -1 this._strip();8259 -18260 -1 var res;8261 -1 if (this.length > 1) {8262 -1 res = 1;8263 -1 } else {8264 -1 if (negative) {8265 -1 num = -num;8266 -1 }8267 -18268 -1 assert(num <= 0x3ffffff, 'Number is too big');8269 -18270 -1 var w = this.words[0] | 0;8271 -1 res = w === num ? 0 : w < num ? -1 : 1;8272 -1 }8273 -1 if (this.negative !== 0) return -res | 0;8274 -1 return res;8275 -1 };8276 -18277 -1 // Compare two numbers and return:8278 -1 // 1 - if `this` > `num`8279 -1 // 0 - if `this` == `num`8280 -1 // -1 - if `this` < `num`8281 -1 BN.prototype.cmp = function cmp (num) {8282 -1 if (this.negative !== 0 && num.negative === 0) return -1;8283 -1 if (this.negative === 0 && num.negative !== 0) return 1;8284 -18285 -1 var res = this.ucmp(num);8286 -1 if (this.negative !== 0) return -res | 0;8287 -1 return res;8288 -1 };8289 -18290 -1 // Unsigned comparison8291 -1 BN.prototype.ucmp = function ucmp (num) {8292 -1 // At this point both numbers have the same sign8293 -1 if (this.length > num.length) return 1;8294 -1 if (this.length < num.length) return -1;8295 -18296 -1 var res = 0;8297 -1 for (var i = this.length - 1; i >= 0; i--) {8298 -1 var a = this.words[i] | 0;8299 -1 var b = num.words[i] | 0;8300 -18301 -1 if (a === b) continue;8302 -1 if (a < b) {8303 -1 res = -1;8304 -1 } else if (a > b) {8305 -1 res = 1;8306 -1 }8307 -1 break;8308 -1 }8309 -1 return res;8310 -1 };8311 -18312 -1 BN.prototype.gtn = function gtn (num) {8313 -1 return this.cmpn(num) === 1;8314 -1 };8315 -18316 -1 BN.prototype.gt = function gt (num) {8317 -1 return this.cmp(num) === 1;8318 -1 };8319 -18320 -1 BN.prototype.gten = function gten (num) {8321 -1 return this.cmpn(num) >= 0;8322 -1 };8323 -18324 -1 BN.prototype.gte = function gte (num) {8325 -1 return this.cmp(num) >= 0;8326 -1 };8327 -18328 -1 BN.prototype.ltn = function ltn (num) {8329 -1 return this.cmpn(num) === -1;8330 -1 };8331 -18332 -1 BN.prototype.lt = function lt (num) {8333 -1 return this.cmp(num) === -1;8334 -1 };8335 -18336 -1 BN.prototype.lten = function lten (num) {8337 -1 return this.cmpn(num) <= 0;8338 -1 };8339 -18340 -1 BN.prototype.lte = function lte (num) {8341 -1 return this.cmp(num) <= 0;8342 -1 };8343 -18344 -1 BN.prototype.eqn = function eqn (num) {8345 -1 return this.cmpn(num) === 0;8346 -1 };8347 -18348 -1 BN.prototype.eq = function eq (num) {8349 -1 return this.cmp(num) === 0;8350 -1 };8351 -18352 -1 //8353 -1 // A reduce context, could be using montgomery or something better, depending8354 -1 // on the `m` itself.8355 -1 //8356 -1 BN.red = function red (num) {8357 -1 return new Red(num);8358 -1 };8359 -18360 -1 BN.prototype.toRed = function toRed (ctx) {8361 -1 assert(!this.red, 'Already a number in reduction context');8362 -1 assert(this.negative === 0, 'red works only with positives');8363 -1 return ctx.convertTo(this)._forceRed(ctx);8364 -1 };8365 -18366 -1 BN.prototype.fromRed = function fromRed () {8367 -1 assert(this.red, 'fromRed works only with numbers in reduction context');8368 -1 return this.red.convertFrom(this);8369 -1 };8370 -18371 -1 BN.prototype._forceRed = function _forceRed (ctx) {8372 -1 this.red = ctx;8373 -1 return this;8374 -1 };8375 -18376 -1 BN.prototype.forceRed = function forceRed (ctx) {8377 -1 assert(!this.red, 'Already a number in reduction context');8378 -1 return this._forceRed(ctx);8379 -1 };8380 -18381 -1 BN.prototype.redAdd = function redAdd (num) {8382 -1 assert(this.red, 'redAdd works only with red numbers');8383 -1 return this.red.add(this, num);8384 -1 };8385 -18386 -1 BN.prototype.redIAdd = function redIAdd (num) {8387 -1 assert(this.red, 'redIAdd works only with red numbers');8388 -1 return this.red.iadd(this, num);8389 -1 };8390 -18391 -1 BN.prototype.redSub = function redSub (num) {8392 -1 assert(this.red, 'redSub works only with red numbers');8393 -1 return this.red.sub(this, num);8394 -1 };8395 -18396 -1 BN.prototype.redISub = function redISub (num) {8397 -1 assert(this.red, 'redISub works only with red numbers');8398 -1 return this.red.isub(this, num);8399 -1 };8400 -18401 -1 BN.prototype.redShl = function redShl (num) {8402 -1 assert(this.red, 'redShl works only with red numbers');8403 -1 return this.red.shl(this, num);8404 -1 };8405 -18406 -1 BN.prototype.redMul = function redMul (num) {8407 -1 assert(this.red, 'redMul works only with red numbers');8408 -1 this.red._verify2(this, num);8409 -1 return this.red.mul(this, num);8410 -1 };8411 -18412 -1 BN.prototype.redIMul = function redIMul (num) {8413 -1 assert(this.red, 'redMul works only with red numbers');8414 -1 this.red._verify2(this, num);8415 -1 return this.red.imul(this, num);8416 -1 };8417 -18418 -1 BN.prototype.redSqr = function redSqr () {8419 -1 assert(this.red, 'redSqr works only with red numbers');8420 -1 this.red._verify1(this);8421 -1 return this.red.sqr(this);8422 -1 };8423 -18424 -1 BN.prototype.redISqr = function redISqr () {8425 -1 assert(this.red, 'redISqr works only with red numbers');8426 -1 this.red._verify1(this);8427 -1 return this.red.isqr(this);8428 -1 };8429 -18430 -1 // Square root over p8431 -1 BN.prototype.redSqrt = function redSqrt () {8432 -1 assert(this.red, 'redSqrt works only with red numbers');8433 -1 this.red._verify1(this);8434 -1 return this.red.sqrt(this);8435 -1 };8436 -18437 -1 BN.prototype.redInvm = function redInvm () {8438 -1 assert(this.red, 'redInvm works only with red numbers');8439 -1 this.red._verify1(this);8440 -1 return this.red.invm(this);8441 -1 };8442 -18443 -1 // Return negative clone of `this` % `red modulo`8444 -1 BN.prototype.redNeg = function redNeg () {8445 -1 assert(this.red, 'redNeg works only with red numbers');8446 -1 this.red._verify1(this);8447 -1 return this.red.neg(this);8448 -1 };8449 -18450 -1 BN.prototype.redPow = function redPow (num) {8451 -1 assert(this.red && !num.red, 'redPow(normalNum)');8452 -1 this.red._verify1(this);8453 -1 return this.red.pow(this, num);8454 -1 };8455 -18456 -1 // Prime numbers with efficient reduction8457 -1 var primes = {8458 -1 k256: null,8459 -1 p224: null,8460 -1 p192: null,8461 -1 p25519: null8462 -1 };8463 -18464 -1 // Pseudo-Mersenne prime8465 -1 function MPrime (name, p) {8466 -1 // P = 2 ^ N - K8467 -1 this.name = name;8468 -1 this.p = new BN(p, 16);8469 -1 this.n = this.p.bitLength();8470 -1 this.k = new BN(1).iushln(this.n).isub(this.p);8471 -18472 -1 this.tmp = this._tmp();8473 -1 }8474 -18475 -1 MPrime.prototype._tmp = function _tmp () {8476 -1 var tmp = new BN(null);8477 -1 tmp.words = new Array(Math.ceil(this.n / 13));8478 -1 return tmp;8479 -1 };8480 -18481 -1 MPrime.prototype.ireduce = function ireduce (num) {8482 -1 // Assumes that `num` is less than `P^2`8483 -1 // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)8484 -1 var r = num;8485 -1 var rlen;8486 -18487 -1 do {8488 -1 this.split(r, this.tmp);8489 -1 r = this.imulK(r);8490 -1 r = r.iadd(this.tmp);8491 -1 rlen = r.bitLength();8492 -1 } while (rlen > this.n);8493 -18494 -1 var cmp = rlen < this.n ? -1 : r.ucmp(this.p);8495 -1 if (cmp === 0) {8496 -1 r.words[0] = 0;8497 -1 r.length = 1;8498 -1 } else if (cmp > 0) {8499 -1 r.isub(this.p);8500 -1 } else {8501 -1 if (r.strip !== undefined) {8502 -1 // r is a BN v4 instance8503 -1 r.strip();8504 -1 } else {8505 -1 // r is a BN v5 instance8506 -1 r._strip();8507 -1 }8508 -1 }8509 -18510 -1 return r;8511 -1 };8512 -18513 -1 MPrime.prototype.split = function split (input, out) {8514 -1 input.iushrn(this.n, 0, out);8515 -1 };8516 -18517 -1 MPrime.prototype.imulK = function imulK (num) {8518 -1 return num.imul(this.k);8519 -1 };8520 -18521 -1 function K256 () {8522 -1 MPrime.call(8523 -1 this,8524 -1 'k256',8525 -1 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');8526 -1 }8527 -1 inherits(K256, MPrime);8528 -18529 -1 K256.prototype.split = function split (input, output) {8530 -1 // 256 = 9 * 26 + 228531 -1 var mask = 0x3fffff;8532 -18533 -1 var outLen = Math.min(input.length, 9);8534 -1 for (var i = 0; i < outLen; i++) {8535 -1 output.words[i] = input.words[i];8536 -1 }8537 -1 output.length = outLen;8538 -18539 -1 if (input.length <= 9) {8540 -1 input.words[0] = 0;8541 -1 input.length = 1;8542 -1 return;8543 -1 }8544 -18545 -1 // Shift by 9 limbs8546 -1 var prev = input.words[9];8547 -1 output.words[output.length++] = prev & mask;8548 -18549 -1 for (i = 10; i < input.length; i++) {8550 -1 var next = input.words[i] | 0;8551 -1 input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);8552 -1 prev = next;8553 -1 }8554 -1 prev >>>= 22;8555 -1 input.words[i - 10] = prev;8556 -1 if (prev === 0 && input.length > 10) {8557 -1 input.length -= 10;8558 -1 } else {8559 -1 input.length -= 9;8560 -1 }8561 -1 };8562 -18563 -1 K256.prototype.imulK = function imulK (num) {8564 -1 // K = 0x1000003d1 = [ 0x40, 0x3d1 ]8565 -1 num.words[num.length] = 0;8566 -1 num.words[num.length + 1] = 0;8567 -1 num.length += 2;8568 -18569 -1 // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x1000003908570 -1 var lo = 0;8571 -1 for (var i = 0; i < num.length; i++) {8572 -1 var w = num.words[i] | 0;8573 -1 lo += w * 0x3d1;8574 -1 num.words[i] = lo & 0x3ffffff;8575 -1 lo = w * 0x40 + ((lo / 0x4000000) | 0);8576 -1 }8577 -18578 -1 // Fast length reduction8579 -1 if (num.words[num.length - 1] === 0) {8580 -1 num.length--;8581 -1 if (num.words[num.length - 1] === 0) {8582 -1 num.length--;8583 -1 }8584 -1 }8585 -1 return num;8586 -1 };8587 -18588 -1 function P224 () {8589 -1 MPrime.call(8590 -1 this,8591 -1 'p224',8592 -1 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');8593 -1 }8594 -1 inherits(P224, MPrime);8595 -18596 -1 function P192 () {8597 -1 MPrime.call(8598 -1 this,8599 -1 'p192',8600 -1 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');8601 -1 }8602 -1 inherits(P192, MPrime);8603 -18604 -1 function P25519 () {8605 -1 // 2 ^ 255 - 198606 -1 MPrime.call(8607 -1 this,8608 -1 '25519',8609 -1 '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');8610 -1 }8611 -1 inherits(P25519, MPrime);8612 -18613 -1 P25519.prototype.imulK = function imulK (num) {8614 -1 // K = 0x138615 -1 var carry = 0;8616 -1 for (var i = 0; i < num.length; i++) {8617 -1 var hi = (num.words[i] | 0) * 0x13 + carry;8618 -1 var lo = hi & 0x3ffffff;8619 -1 hi >>>= 26;8620 -18621 -1 num.words[i] = lo;8622 -1 carry = hi;8623 -1 }8624 -1 if (carry !== 0) {8625 -1 num.words[num.length++] = carry;8626 -1 }8627 -1 return num;8628 -1 };8629 -18630 -1 // Exported mostly for testing purposes, use plain name instead8631 -1 BN._prime = function prime (name) {8632 -1 // Cached version of prime8633 -1 if (primes[name]) return primes[name];8634 -18635 -1 var prime;8636 -1 if (name === 'k256') {8637 -1 prime = new K256();8638 -1 } else if (name === 'p224') {8639 -1 prime = new P224();8640 -1 } else if (name === 'p192') {8641 -1 prime = new P192();8642 -1 } else if (name === 'p25519') {8643 -1 prime = new P25519();8644 -1 } else {8645 -1 throw new Error('Unknown prime ' + name);8646 -1 }8647 -1 primes[name] = prime;8648 -18649 -1 return prime;8650 -1 };8651 -18652 -1 //8653 -1 // Base reduction engine8654 -1 //8655 -1 function Red (m) {8656 -1 if (typeof m === 'string') {8657 -1 var prime = BN._prime(m);8658 -1 this.m = prime.p;8659 -1 this.prime = prime;8660 -1 } else {8661 -1 assert(m.gtn(1), 'modulus must be greater than 1');8662 -1 this.m = m;8663 -1 this.prime = null;8664 -1 }8665 -1 }8666 -18667 -1 Red.prototype._verify1 = function _verify1 (a) {8668 -1 assert(a.negative === 0, 'red works only with positives');8669 -1 assert(a.red, 'red works only with red numbers');8670 -1 };8671 -18672 -1 Red.prototype._verify2 = function _verify2 (a, b) {8673 -1 assert((a.negative | b.negative) === 0, 'red works only with positives');8674 -1 assert(a.red && a.red === b.red,8675 -1 'red works only with red numbers');8676 -1 };8677 -18678 -1 Red.prototype.imod = function imod (a) {8679 -1 if (this.prime) return this.prime.ireduce(a)._forceRed(this);8680 -18681 -1 move(a, a.umod(this.m)._forceRed(this));8682 -1 return a;8683 -1 };8684 -18685 -1 Red.prototype.neg = function neg (a) {8686 -1 if (a.isZero()) {8687 -1 return a.clone();8688 -1 }8689 -18690 -1 return this.m.sub(a)._forceRed(this);8691 -1 };8692 -18693 -1 Red.prototype.add = function add (a, b) {8694 -1 this._verify2(a, b);8695 -18696 -1 var res = a.add(b);8697 -1 if (res.cmp(this.m) >= 0) {8698 -1 res.isub(this.m);8699 -1 }8700 -1 return res._forceRed(this);8701 -1 };8702 -18703 -1 Red.prototype.iadd = function iadd (a, b) {8704 -1 this._verify2(a, b);8705 -18706 -1 var res = a.iadd(b);8707 -1 if (res.cmp(this.m) >= 0) {8708 -1 res.isub(this.m);8709 -1 }8710 -1 return res;8711 -1 };8712 -18713 -1 Red.prototype.sub = function sub (a, b) {8714 -1 this._verify2(a, b);8715 -18716 -1 var res = a.sub(b);8717 -1 if (res.cmpn(0) < 0) {8718 -1 res.iadd(this.m);8719 -1 }8720 -1 return res._forceRed(this);8721 -1 };8722 -18723 -1 Red.prototype.isub = function isub (a, b) {8724 -1 this._verify2(a, b);8725 -18726 -1 var res = a.isub(b);8727 -1 if (res.cmpn(0) < 0) {8728 -1 res.iadd(this.m);8729 -1 }8730 -1 return res;8731 -1 };8732 -18733 -1 Red.prototype.shl = function shl (a, num) {8734 -1 this._verify1(a);8735 -1 return this.imod(a.ushln(num));8736 -1 };8737 -18738 -1 Red.prototype.imul = function imul (a, b) {8739 -1 this._verify2(a, b);8740 -1 return this.imod(a.imul(b));8741 -1 };8742 -18743 -1 Red.prototype.mul = function mul (a, b) {8744 -1 this._verify2(a, b);8745 -1 return this.imod(a.mul(b));8746 -1 };8747 -18748 -1 Red.prototype.isqr = function isqr (a) {8749 -1 return this.imul(a, a.clone());8750 -1 };8751 -18752 -1 Red.prototype.sqr = function sqr (a) {8753 -1 return this.mul(a, a);8754 -1 };8755 -18756 -1 Red.prototype.sqrt = function sqrt (a) {8757 -1 if (a.isZero()) return a.clone();8758 -18759 -1 var mod3 = this.m.andln(3);8760 -1 assert(mod3 % 2 === 1);8761 -18762 -1 // Fast case8763 -1 if (mod3 === 3) {8764 -1 var pow = this.m.add(new BN(1)).iushrn(2);8765 -1 return this.pow(a, pow);8766 -1 }8767 -18768 -1 // Tonelli-Shanks algorithm (Totally unoptimized and slow)8769 -1 //8770 -1 // Find Q and S, that Q * 2 ^ S = (P - 1)8771 -1 var q = this.m.subn(1);8772 -1 var s = 0;8773 -1 while (!q.isZero() && q.andln(1) === 0) {8774 -1 s++;8775 -1 q.iushrn(1);8776 -1 }8777 -1 assert(!q.isZero());8778 -18779 -1 var one = new BN(1).toRed(this);8780 -1 var nOne = one.redNeg();8781 -18782 -1 // Find quadratic non-residue8783 -1 // NOTE: Max is such because of generalized Riemann hypothesis.8784 -1 var lpow = this.m.subn(1).iushrn(1);8785 -1 var z = this.m.bitLength();8786 -1 z = new BN(2 * z * z).toRed(this);8787 -18788 -1 while (this.pow(z, lpow).cmp(nOne) !== 0) {8789 -1 z.redIAdd(nOne);8790 -1 }8791 -18792 -1 var c = this.pow(z, q);8793 -1 var r = this.pow(a, q.addn(1).iushrn(1));8794 -1 var t = this.pow(a, q);8795 -1 var m = s;8796 -1 while (t.cmp(one) !== 0) {8797 -1 var tmp = t;8798 -1 for (var i = 0; tmp.cmp(one) !== 0; i++) {8799 -1 tmp = tmp.redSqr();8800 -1 }8801 -1 assert(i < m);8802 -1 var b = this.pow(c, new BN(1).iushln(m - i - 1));8803 -18804 -1 r = r.redMul(b);8805 -1 c = b.redSqr();8806 -1 t = t.redMul(c);8807 -1 m = i;8808 -1 }8809 -18810 -1 return r;8811 -1 };8812 -18813 -1 Red.prototype.invm = function invm (a) {8814 -1 var inv = a._invmp(this.m);8815 -1 if (inv.negative !== 0) {8816 -1 inv.negative = 0;8817 -1 return this.imod(inv).redNeg();8818 -1 } else {8819 -1 return this.imod(inv);8820 -1 }8821 -1 };8822 -18823 -1 Red.prototype.pow = function pow (a, num) {8824 -1 if (num.isZero()) return new BN(1).toRed(this);8825 -1 if (num.cmpn(1) === 0) return a.clone();8826 -18827 -1 var windowSize = 4;8828 -1 var wnd = new Array(1 << windowSize);8829 -1 wnd[0] = new BN(1).toRed(this);8830 -1 wnd[1] = a;8831 -1 for (var i = 2; i < wnd.length; i++) {8832 -1 wnd[i] = this.mul(wnd[i - 1], a);8833 -1 }8834 -18835 -1 var res = wnd[0];8836 -1 var current = 0;8837 -1 var currentLen = 0;8838 -1 var start = num.bitLength() % 26;8839 -1 if (start === 0) {8840 -1 start = 26;8841 -1 }8842 -18843 -1 for (i = num.length - 1; i >= 0; i--) {8844 -1 var word = num.words[i];8845 -1 for (var j = start - 1; j >= 0; j--) {8846 -1 var bit = (word >> j) & 1;8847 -1 if (res !== wnd[0]) {8848 -1 res = this.sqr(res);8849 -1 }8850 -18851 -1 if (bit === 0 && current === 0) {8852 -1 currentLen = 0;8853 -1 continue;8854 -1 }8855 -18856 -1 current <<= 1;8857 -1 current |= bit;8858 -1 currentLen++;8859 -1 if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;8860 -18861 -1 res = this.mul(res, wnd[current]);8862 -1 currentLen = 0;8863 -1 current = 0;8864 -1 }8865 -1 start = 26;8866 -1 }8867 -18868 -1 return res;8869 -1 };8870 -18871 -1 Red.prototype.convertTo = function convertTo (num) {8872 -1 var r = num.umod(this.m);8873 -18874 -1 return r === num ? r.clone() : r;8875 -1 };8876 -18877 -1 Red.prototype.convertFrom = function convertFrom (num) {8878 -1 var res = num.clone();8879 -1 res.red = null;8880 -1 return res;8881 -1 };8882 -18883 -1 //8884 -1 // Montgomery method engine8885 -1 //8886 -18887 -1 BN.mont = function mont (num) {8888 -1 return new Mont(num);8889 -1 };8890 -18891 -1 function Mont (m) {8892 -1 Red.call(this, m);8893 -18894 -1 this.shift = this.m.bitLength();8895 -1 if (this.shift % 26 !== 0) {8896 -1 this.shift += 26 - (this.shift % 26);8897 -1 }8898 -18899 -1 this.r = new BN(1).iushln(this.shift);8900 -1 this.r2 = this.imod(this.r.sqr());8901 -1 this.rinv = this.r._invmp(this.m);8902 -18903 -1 this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);8904 -1 this.minv = this.minv.umod(this.r);8905 -1 this.minv = this.r.sub(this.minv);8906 -1 }8907 -1 inherits(Mont, Red);8908 -18909 -1 Mont.prototype.convertTo = function convertTo (num) {8910 -1 return this.imod(num.ushln(this.shift));8911 -1 };8912 -18913 -1 Mont.prototype.convertFrom = function convertFrom (num) {8914 -1 var r = this.imod(num.mul(this.rinv));8915 -1 r.red = null;8916 -1 return r;8917 -1 };8918 -18919 -1 Mont.prototype.imul = function imul (a, b) {8920 -1 if (a.isZero() || b.isZero()) {8921 -1 a.words[0] = 0;8922 -1 a.length = 1;8923 -1 return a;8924 -1 }8925 -18926 -1 var t = a.imul(b);8927 -1 var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);8928 -1 var u = t.isub(c).iushrn(this.shift);8929 -1 var res = u;8930 -18931 -1 if (u.cmp(this.m) >= 0) {8932 -1 res = u.isub(this.m);8933 -1 } else if (u.cmpn(0) < 0) {8934 -1 res = u.iadd(this.m);8935 -1 }8936 -18937 -1 return res._forceRed(this);8938 -1 };8939 -18940 -1 Mont.prototype.mul = function mul (a, b) {8941 -1 if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);8942 -18943 -1 var t = a.mul(b);8944 -1 var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);8945 -1 var u = t.isub(c).iushrn(this.shift);8946 -1 var res = u;8947 -1 if (u.cmp(this.m) >= 0) {8948 -1 res = u.isub(this.m);8949 -1 } else if (u.cmpn(0) < 0) {8950 -1 res = u.iadd(this.m);8951 -1 }8952 -18953 -1 return res._forceRed(this);8954 -1 };8955 -18956 -1 Mont.prototype.invm = function invm (a) {8957 -1 // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R8958 -1 var res = this.imod(a._invmp(this.m).mul(this.r2));8959 -1 return res._forceRed(this);8960 -1 };8961 -1 })(typeof module === 'undefined' || module, this);8962 -18963 -1 },{"buffer":19}],18:[function(require,module,exports){8964 -1 var r;8965 -18966 -1 module.exports = function rand(len) {8967 -1 if (!r)8968 -1 r = new Rand(null);8969 -18970 -1 return r.generate(len);8971 -1 };8972 -18973 -1 function Rand(rand) {8974 -1 this.rand = rand;8975 -1 }8976 -1 module.exports.Rand = Rand;8977 -18978 -1 Rand.prototype.generate = function generate(len) {8979 -1 return this._rand(len);8980 -1 };8981 -18982 -1 // Emulate crypto API using randy8983 -1 Rand.prototype._rand = function _rand(n) {8984 -1 if (this.rand.getBytes)8985 -1 return this.rand.getBytes(n);8986 -18987 -1 var res = new Uint8Array(n);8988 -1 for (var i = 0; i < res.length; i++)8989 -1 res[i] = this.rand.getByte();8990 -1 return res;8991 -1 };8992 -18993 -1 if (typeof self === 'object') {8994 -1 if (self.crypto && self.crypto.getRandomValues) {8995 -1 // Modern browsers8996 -1 Rand.prototype._rand = function _rand(n) {8997 -1 var arr = new Uint8Array(n);8998 -1 self.crypto.getRandomValues(arr);8999 -1 return arr;9000 -1 };9001 -1 } else if (self.msCrypto && self.msCrypto.getRandomValues) {9002 -1 // IE9003 -1 Rand.prototype._rand = function _rand(n) {9004 -1 var arr = new Uint8Array(n);9005 -1 self.msCrypto.getRandomValues(arr);9006 -1 return arr;9007 -1 };9008 -19009 -1 // Safari's WebWorkers do not have `crypto`9010 -1 } else if (typeof window === 'object') {9011 -1 // Old junk9012 -1 Rand.prototype._rand = function() {9013 -1 throw new Error('Not implemented yet');9014 -1 };9015 -1 }9016 -1 } else {9017 -1 // Node.js or Web worker with no crypto support9018 -1 try {9019 -1 var crypto = require('crypto');9020 -1 if (typeof crypto.randomBytes !== 'function')9021 -1 throw new Error('Not supported');9022 -19023 -1 Rand.prototype._rand = function _rand(n) {9024 -1 return crypto.randomBytes(n);9025 -1 };9026 -1 } catch (e) {9027 -1 }9028 -1 }9029 -19030 -1 },{"crypto":19}],19:[function(require,module,exports){9031 -19032 -1 },{}],20:[function(require,module,exports){9033 -1 // based on the aes implimentation in triple sec9034 -1 // https://github.com/keybase/triplesec9035 -1 // which is in turn based on the one from crypto-js9036 -1 // https://code.google.com/p/crypto-js/9037 -19038 -1 var Buffer = require('safe-buffer').Buffer9039 -19040 -1 function asUInt32Array (buf) {9041 -1 if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)9042 -19043 -1 var len = (buf.length / 4) | 09044 -1 var out = new Array(len)9045 -19046 -1 for (var i = 0; i < len; i++) {9047 -1 out[i] = buf.readUInt32BE(i * 4)9048 -1 }9049 -19050 -1 return out9051 -1 }9052 -19053 -1 function scrubVec (v) {9054 -1 for (var i = 0; i < v.length; v++) {9055 -1 v[i] = 09056 -1 }9057 -1 }9058 -19059 -1 function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) {9060 -1 var SUB_MIX0 = SUB_MIX[0]9061 -1 var SUB_MIX1 = SUB_MIX[1]9062 -1 var SUB_MIX2 = SUB_MIX[2]9063 -1 var SUB_MIX3 = SUB_MIX[3]9064 -19065 -1 var s0 = M[0] ^ keySchedule[0]9066 -1 var s1 = M[1] ^ keySchedule[1]9067 -1 var s2 = M[2] ^ keySchedule[2]9068 -1 var s3 = M[3] ^ keySchedule[3]9069 -1 var t0, t1, t2, t39070 -1 var ksRow = 49071 -19072 -1 for (var round = 1; round < nRounds; round++) {9073 -1 t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++]9074 -1 t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++]9075 -1 t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[(s3 >>> 16) & 0xff] ^ SUB_MIX2[(s0 >>> 8) & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++]9076 -1 t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[(s0 >>> 16) & 0xff] ^ SUB_MIX2[(s1 >>> 8) & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++]9077 -1 s0 = t09078 -1 s1 = t19079 -1 s2 = t29080 -1 s3 = t39081 -1 }9082 -19083 -1 t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]9084 -1 t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]9085 -1 t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]9086 -1 t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]9087 -1 t0 = t0 >>> 09088 -1 t1 = t1 >>> 09089 -1 t2 = t2 >>> 09090 -1 t3 = t3 >>> 09091 -19092 -1 return [t0, t1, t2, t3]9093 -1 }9094 -19095 -1 // AES constants9096 -1 var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]9097 -1 var G = (function () {9098 -1 // Compute double table9099 -1 var d = new Array(256)9100 -1 for (var j = 0; j < 256; j++) {9101 -1 if (j < 128) {9102 -1 d[j] = j << 19103 -1 } else {9104 -1 d[j] = (j << 1) ^ 0x11b9105 -1 }9106 -1 }9107 -19108 -1 var SBOX = []9109 -1 var INV_SBOX = []9110 -1 var SUB_MIX = [[], [], [], []]9111 -1 var INV_SUB_MIX = [[], [], [], []]9112 -19113 -1 // Walk GF(2^8)9114 -1 var x = 09115 -1 var xi = 09116 -1 for (var i = 0; i < 256; ++i) {9117 -1 // Compute sbox9118 -1 var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4)9119 -1 sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x639120 -1 SBOX[x] = sx9121 -1 INV_SBOX[sx] = x9122 -19123 -1 // Compute multiplication9124 -1 var x2 = d[x]9125 -1 var x4 = d[x2]9126 -1 var x8 = d[x4]9127 -19128 -1 // Compute sub bytes, mix columns tables9129 -1 var t = (d[sx] * 0x101) ^ (sx * 0x1010100)9130 -1 SUB_MIX[0][x] = (t << 24) | (t >>> 8)9131 -1 SUB_MIX[1][x] = (t << 16) | (t >>> 16)9132 -1 SUB_MIX[2][x] = (t << 8) | (t >>> 24)9133 -1 SUB_MIX[3][x] = t9134 -19135 -1 // Compute inv sub bytes, inv mix columns tables9136 -1 t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100)9137 -1 INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8)9138 -1 INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16)9139 -1 INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24)9140 -1 INV_SUB_MIX[3][sx] = t9141 -19142 -1 if (x === 0) {9143 -1 x = xi = 19144 -1 } else {9145 -1 x = x2 ^ d[d[d[x8 ^ x2]]]9146 -1 xi ^= d[d[xi]]9147 -1 }9148 -1 }9149 -19150 -1 return {9151 -1 SBOX: SBOX,9152 -1 INV_SBOX: INV_SBOX,9153 -1 SUB_MIX: SUB_MIX,9154 -1 INV_SUB_MIX: INV_SUB_MIX9155 -1 }9156 -1 })()9157 -19158 -1 function AES (key) {9159 -1 this._key = asUInt32Array(key)9160 -1 this._reset()9161 -1 }9162 -19163 -1 AES.blockSize = 4 * 49164 -1 AES.keySize = 256 / 89165 -1 AES.prototype.blockSize = AES.blockSize9166 -1 AES.prototype.keySize = AES.keySize9167 -1 AES.prototype._reset = function () {9168 -1 var keyWords = this._key9169 -1 var keySize = keyWords.length9170 -1 var nRounds = keySize + 69171 -1 var ksRows = (nRounds + 1) * 49172 -19173 -1 var keySchedule = []9174 -1 for (var k = 0; k < keySize; k++) {9175 -1 keySchedule[k] = keyWords[k]9176 -1 }9177 -19178 -1 for (k = keySize; k < ksRows; k++) {9179 -1 var t = keySchedule[k - 1]9180 -19181 -1 if (k % keySize === 0) {9182 -1 t = (t << 8) | (t >>> 24)9183 -1 t =9184 -1 (G.SBOX[t >>> 24] << 24) |9185 -1 (G.SBOX[(t >>> 16) & 0xff] << 16) |9186 -1 (G.SBOX[(t >>> 8) & 0xff] << 8) |9187 -1 (G.SBOX[t & 0xff])9188 -19189 -1 t ^= RCON[(k / keySize) | 0] << 249190 -1 } else if (keySize > 6 && k % keySize === 4) {9191 -1 t =9192 -1 (G.SBOX[t >>> 24] << 24) |9193 -1 (G.SBOX[(t >>> 16) & 0xff] << 16) |9194 -1 (G.SBOX[(t >>> 8) & 0xff] << 8) |9195 -1 (G.SBOX[t & 0xff])9196 -1 }9197 -19198 -1 keySchedule[k] = keySchedule[k - keySize] ^ t9199 -1 }9200 -19201 -1 var invKeySchedule = []9202 -1 for (var ik = 0; ik < ksRows; ik++) {9203 -1 var ksR = ksRows - ik9204 -1 var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)]9205 -19206 -1 if (ik < 4 || ksR <= 4) {9207 -1 invKeySchedule[ik] = tt9208 -1 } else {9209 -1 invKeySchedule[ik] =9210 -1 G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^9211 -1 G.INV_SUB_MIX[1][G.SBOX[(tt >>> 16) & 0xff]] ^9212 -1 G.INV_SUB_MIX[2][G.SBOX[(tt >>> 8) & 0xff]] ^9213 -1 G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]]9214 -1 }9215 -1 }9216 -19217 -1 this._nRounds = nRounds9218 -1 this._keySchedule = keySchedule9219 -1 this._invKeySchedule = invKeySchedule9220 -1 }9221 -19222 -1 AES.prototype.encryptBlockRaw = function (M) {9223 -1 M = asUInt32Array(M)9224 -1 return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds)9225 -1 }9226 -19227 -1 AES.prototype.encryptBlock = function (M) {9228 -1 var out = this.encryptBlockRaw(M)9229 -1 var buf = Buffer.allocUnsafe(16)9230 -1 buf.writeUInt32BE(out[0], 0)9231 -1 buf.writeUInt32BE(out[1], 4)9232 -1 buf.writeUInt32BE(out[2], 8)9233 -1 buf.writeUInt32BE(out[3], 12)9234 -1 return buf9235 -1 }9236 -19237 -1 AES.prototype.decryptBlock = function (M) {9238 -1 M = asUInt32Array(M)9239 -19240 -1 // swap9241 -1 var m1 = M[1]9242 -1 M[1] = M[3]9243 -1 M[3] = m19244 -19245 -1 var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds)9246 -1 var buf = Buffer.allocUnsafe(16)9247 -1 buf.writeUInt32BE(out[0], 0)9248 -1 buf.writeUInt32BE(out[3], 4)9249 -1 buf.writeUInt32BE(out[2], 8)9250 -1 buf.writeUInt32BE(out[1], 12)9251 -1 return buf9252 -1 }9253 -19254 -1 AES.prototype.scrub = function () {9255 -1 scrubVec(this._keySchedule)9256 -1 scrubVec(this._invKeySchedule)9257 -1 scrubVec(this._key)9258 -1 }9259 -19260 -1 module.exports.AES = AES9261 -19262 -1 },{"safe-buffer":160}],21:[function(require,module,exports){9263 -1 var aes = require('./aes')9264 -1 var Buffer = require('safe-buffer').Buffer9265 -1 var Transform = require('cipher-base')9266 -1 var inherits = require('inherits')9267 -1 var GHASH = require('./ghash')9268 -1 var xor = require('buffer-xor')9269 -1 var incr32 = require('./incr32')9270 -19271 -1 function xorTest (a, b) {9272 -1 var out = 09273 -1 if (a.length !== b.length) out++9274 -19275 -1 var len = Math.min(a.length, b.length)9276 -1 for (var i = 0; i < len; ++i) {9277 -1 out += (a[i] ^ b[i])9278 -1 }9279 -19280 -1 return out9281 -1 }9282 -19283 -1 function calcIv (self, iv, ck) {9284 -1 if (iv.length === 12) {9285 -1 self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])])9286 -1 return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])])9287 -1 }9288 -1 var ghash = new GHASH(ck)9289 -1 var len = iv.length9290 -1 var toPad = len % 169291 -1 ghash.update(iv)9292 -1 if (toPad) {9293 -1 toPad = 16 - toPad9294 -1 ghash.update(Buffer.alloc(toPad, 0))9295 -1 }9296 -1 ghash.update(Buffer.alloc(8, 0))9297 -1 var ivBits = len * 89298 -1 var tail = Buffer.alloc(8)9299 -1 tail.writeUIntBE(ivBits, 0, 8)9300 -1 ghash.update(tail)9301 -1 self._finID = ghash.state9302 -1 var out = Buffer.from(self._finID)9303 -1 incr32(out)9304 -1 return out9305 -1 }9306 -1 function StreamCipher (mode, key, iv, decrypt) {9307 -1 Transform.call(this)9308 -19309 -1 var h = Buffer.alloc(4, 0)9310 -19311 -1 this._cipher = new aes.AES(key)9312 -1 var ck = this._cipher.encryptBlock(h)9313 -1 this._ghash = new GHASH(ck)9314 -1 iv = calcIv(this, iv, ck)9315 -19316 -1 this._prev = Buffer.from(iv)9317 -1 this._cache = Buffer.allocUnsafe(0)9318 -1 this._secCache = Buffer.allocUnsafe(0)9319 -1 this._decrypt = decrypt9320 -1 this._alen = 09321 -1 this._len = 09322 -1 this._mode = mode9323 -19324 -1 this._authTag = null9325 -1 this._called = false9326 -1 }9327 -19328 -1 inherits(StreamCipher, Transform)9329 -19330 -1 StreamCipher.prototype._update = function (chunk) {9331 -1 if (!this._called && this._alen) {9332 -1 var rump = 16 - (this._alen % 16)9333 -1 if (rump < 16) {9334 -1 rump = Buffer.alloc(rump, 0)9335 -1 this._ghash.update(rump)9336 -1 }9337 -1 }9338 -19339 -1 this._called = true9340 -1 var out = this._mode.encrypt(this, chunk)9341 -1 if (this._decrypt) {9342 -1 this._ghash.update(chunk)9343 -1 } else {9344 -1 this._ghash.update(out)9345 -1 }9346 -1 this._len += chunk.length9347 -1 return out9348 -1 }9349 -19350 -1 StreamCipher.prototype._final = function () {9351 -1 if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data')9352 -19353 -1 var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID))9354 -1 if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data')9355 -19356 -1 this._authTag = tag9357 -1 this._cipher.scrub()9358 -1 }9359 -19360 -1 StreamCipher.prototype.getAuthTag = function getAuthTag () {9361 -1 if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state')9362 -19363 -1 return this._authTag9364 -1 }9365 -19366 -1 StreamCipher.prototype.setAuthTag = function setAuthTag (tag) {9367 -1 if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state')9368 -19369 -1 this._authTag = tag9370 -1 }9371 -19372 -1 StreamCipher.prototype.setAAD = function setAAD (buf) {9373 -1 if (this._called) throw new Error('Attempting to set AAD in unsupported state')9374 -19375 -1 this._ghash.update(buf)9376 -1 this._alen += buf.length9377 -1 }9378 -19379 -1 module.exports = StreamCipher9380 -19381 -1 },{"./aes":20,"./ghash":25,"./incr32":26,"buffer-xor":62,"cipher-base":64,"inherits":132,"safe-buffer":160}],22:[function(require,module,exports){9382 -1 var ciphers = require('./encrypter')9383 -1 var deciphers = require('./decrypter')9384 -1 var modes = require('./modes/list.json')9385 -19386 -1 function getCiphers () {9387 -1 return Object.keys(modes)9388 -1 }9389 -19390 -1 exports.createCipher = exports.Cipher = ciphers.createCipher9391 -1 exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv9392 -1 exports.createDecipher = exports.Decipher = deciphers.createDecipher9393 -1 exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv9394 -1 exports.listCiphers = exports.getCiphers = getCiphers9395 -19396 -1 },{"./decrypter":23,"./encrypter":24,"./modes/list.json":34}],23:[function(require,module,exports){9397 -1 var AuthCipher = require('./authCipher')9398 -1 var Buffer = require('safe-buffer').Buffer9399 -1 var MODES = require('./modes')9400 -1 var StreamCipher = require('./streamCipher')9401 -1 var Transform = require('cipher-base')9402 -1 var aes = require('./aes')9403 -1 var ebtk = require('evp_bytestokey')9404 -1 var inherits = require('inherits')9405 -19406 -1 function Decipher (mode, key, iv) {9407 -1 Transform.call(this)9408 -19409 -1 this._cache = new Splitter()9410 -1 this._last = void 09411 -1 this._cipher = new aes.AES(key)9412 -1 this._prev = Buffer.from(iv)9413 -1 this._mode = mode9414 -1 this._autopadding = true9415 -1 }9416 -19417 -1 inherits(Decipher, Transform)9418 -19419 -1 Decipher.prototype._update = function (data) {9420 -1 this._cache.add(data)9421 -1 var chunk9422 -1 var thing9423 -1 var out = []9424 -1 while ((chunk = this._cache.get(this._autopadding))) {9425 -1 thing = this._mode.decrypt(this, chunk)9426 -1 out.push(thing)9427 -1 }9428 -1 return Buffer.concat(out)9429 -1 }9430 -19431 -1 Decipher.prototype._final = function () {9432 -1 var chunk = this._cache.flush()9433 -1 if (this._autopadding) {9434 -1 return unpad(this._mode.decrypt(this, chunk))9435 -1 } else if (chunk) {9436 -1 throw new Error('data not multiple of block length')9437 -1 }9438 -1 }9439 -19440 -1 Decipher.prototype.setAutoPadding = function (setTo) {9441 -1 this._autopadding = !!setTo9442 -1 return this9443 -1 }9444 -19445 -1 function Splitter () {9446 -1 this.cache = Buffer.allocUnsafe(0)9447 -1 }9448 -19449 -1 Splitter.prototype.add = function (data) {9450 -1 this.cache = Buffer.concat([this.cache, data])9451 -1 }9452 -19453 -1 Splitter.prototype.get = function (autoPadding) {9454 -1 var out9455 -1 if (autoPadding) {9456 -1 if (this.cache.length > 16) {9457 -1 out = this.cache.slice(0, 16)9458 -1 this.cache = this.cache.slice(16)9459 -1 return out9460 -1 }9461 -1 } else {9462 -1 if (this.cache.length >= 16) {9463 -1 out = this.cache.slice(0, 16)9464 -1 this.cache = this.cache.slice(16)9465 -1 return out9466 -1 }9467 -1 }9468 -19469 -1 return null9470 -1 }9471 -19472 -1 Splitter.prototype.flush = function () {9473 -1 if (this.cache.length) return this.cache9474 -1 }9475 -19476 -1 function unpad (last) {9477 -1 var padded = last[15]9478 -1 if (padded < 1 || padded > 16) {9479 -1 throw new Error('unable to decrypt data')9480 -1 }9481 -1 var i = -19482 -1 while (++i < padded) {9483 -1 if (last[(i + (16 - padded))] !== padded) {9484 -1 throw new Error('unable to decrypt data')9485 -1 }9486 -1 }9487 -1 if (padded === 16) return9488 -19489 -1 return last.slice(0, 16 - padded)9490 -1 }9491 -19492 -1 function createDecipheriv (suite, password, iv) {9493 -1 var config = MODES[suite.toLowerCase()]9494 -1 if (!config) throw new TypeError('invalid suite type')9495 -19496 -1 if (typeof iv === 'string') iv = Buffer.from(iv)9497 -1 if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)9498 -19499 -1 if (typeof password === 'string') password = Buffer.from(password)9500 -1 if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)9501 -19502 -1 if (config.type === 'stream') {9503 -1 return new StreamCipher(config.module, password, iv, true)9504 -1 } else if (config.type === 'auth') {9505 -1 return new AuthCipher(config.module, password, iv, true)9506 -1 }9507 -19508 -1 return new Decipher(config.module, password, iv)9509 -1 }9510 -19511 -1 function createDecipher (suite, password) {9512 -1 var config = MODES[suite.toLowerCase()]9513 -1 if (!config) throw new TypeError('invalid suite type')9514 -19515 -1 var keys = ebtk(password, false, config.key, config.iv)9516 -1 return createDecipheriv(suite, keys.key, keys.iv)9517 -1 }9518 -19519 -1 exports.createDecipher = createDecipher9520 -1 exports.createDecipheriv = createDecipheriv9521 -19522 -1 },{"./aes":20,"./authCipher":21,"./modes":33,"./streamCipher":36,"cipher-base":64,"evp_bytestokey":101,"inherits":132,"safe-buffer":160}],24:[function(require,module,exports){9523 -1 var MODES = require('./modes')9524 -1 var AuthCipher = require('./authCipher')9525 -1 var Buffer = require('safe-buffer').Buffer9526 -1 var StreamCipher = require('./streamCipher')9527 -1 var Transform = require('cipher-base')9528 -1 var aes = require('./aes')9529 -1 var ebtk = require('evp_bytestokey')9530 -1 var inherits = require('inherits')9531 -19532 -1 function Cipher (mode, key, iv) {9533 -1 Transform.call(this)9534 -19535 -1 this._cache = new Splitter()9536 -1 this._cipher = new aes.AES(key)9537 -1 this._prev = Buffer.from(iv)9538 -1 this._mode = mode9539 -1 this._autopadding = true9540 -1 }9541 -19542 -1 inherits(Cipher, Transform)9543 -19544 -1 Cipher.prototype._update = function (data) {9545 -1 this._cache.add(data)9546 -1 var chunk9547 -1 var thing9548 -1 var out = []9549 -19550 -1 while ((chunk = this._cache.get())) {9551 -1 thing = this._mode.encrypt(this, chunk)9552 -1 out.push(thing)9553 -1 }9554 -19555 -1 return Buffer.concat(out)9556 -1 }9557 -19558 -1 var PADDING = Buffer.alloc(16, 0x10)9559 -19560 -1 Cipher.prototype._final = function () {9561 -1 var chunk = this._cache.flush()9562 -1 if (this._autopadding) {9563 -1 chunk = this._mode.encrypt(this, chunk)9564 -1 this._cipher.scrub()9565 -1 return chunk9566 -1 }9567 -19568 -1 if (!chunk.equals(PADDING)) {9569 -1 this._cipher.scrub()9570 -1 throw new Error('data not multiple of block length')9571 -1 }9572 -1 }9573 -19574 -1 Cipher.prototype.setAutoPadding = function (setTo) {9575 -1 this._autopadding = !!setTo9576 -1 return this9577 -1 }9578 -19579 -1 function Splitter () {9580 -1 this.cache = Buffer.allocUnsafe(0)9581 -1 }9582 -19583 -1 Splitter.prototype.add = function (data) {9584 -1 this.cache = Buffer.concat([this.cache, data])9585 -1 }9586 -19587 -1 Splitter.prototype.get = function () {9588 -1 if (this.cache.length > 15) {9589 -1 var out = this.cache.slice(0, 16)9590 -1 this.cache = this.cache.slice(16)9591 -1 return out9592 -1 }9593 -1 return null9594 -1 }9595 -19596 -1 Splitter.prototype.flush = function () {9597 -1 var len = 16 - this.cache.length9598 -1 var padBuff = Buffer.allocUnsafe(len)9599 -19600 -1 var i = -19601 -1 while (++i < len) {9602 -1 padBuff.writeUInt8(len, i)9603 -1 }9604 -19605 -1 return Buffer.concat([this.cache, padBuff])9606 -1 }9607 -19608 -1 function createCipheriv (suite, password, iv) {9609 -1 var config = MODES[suite.toLowerCase()]9610 -1 if (!config) throw new TypeError('invalid suite type')9611 -19612 -1 if (typeof password === 'string') password = Buffer.from(password)9613 -1 if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)9614 -19615 -1 if (typeof iv === 'string') iv = Buffer.from(iv)9616 -1 if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)9617 -19618 -1 if (config.type === 'stream') {9619 -1 return new StreamCipher(config.module, password, iv)9620 -1 } else if (config.type === 'auth') {9621 -1 return new AuthCipher(config.module, password, iv)9622 -1 }9623 -19624 -1 return new Cipher(config.module, password, iv)9625 -1 }9626 -19627 -1 function createCipher (suite, password) {9628 -1 var config = MODES[suite.toLowerCase()]9629 -1 if (!config) throw new TypeError('invalid suite type')9630 -19631 -1 var keys = ebtk(password, false, config.key, config.iv)9632 -1 return createCipheriv(suite, keys.key, keys.iv)9633 -1 }9634 -19635 -1 exports.createCipheriv = createCipheriv9636 -1 exports.createCipher = createCipher9637 -19638 -1 },{"./aes":20,"./authCipher":21,"./modes":33,"./streamCipher":36,"cipher-base":64,"evp_bytestokey":101,"inherits":132,"safe-buffer":160}],25:[function(require,module,exports){9639 -1 var Buffer = require('safe-buffer').Buffer9640 -1 var ZEROES = Buffer.alloc(16, 0)9641 -19642 -1 function toArray (buf) {9643 -1 return [9644 -1 buf.readUInt32BE(0),9645 -1 buf.readUInt32BE(4),9646 -1 buf.readUInt32BE(8),9647 -1 buf.readUInt32BE(12)9648 -1 ]9649 -1 }9650 -19651 -1 function fromArray (out) {9652 -1 var buf = Buffer.allocUnsafe(16)9653 -1 buf.writeUInt32BE(out[0] >>> 0, 0)9654 -1 buf.writeUInt32BE(out[1] >>> 0, 4)9655 -1 buf.writeUInt32BE(out[2] >>> 0, 8)9656 -1 buf.writeUInt32BE(out[3] >>> 0, 12)9657 -1 return buf9658 -1 }9659 -19660 -1 function GHASH (key) {9661 -1 this.h = key9662 -1 this.state = Buffer.alloc(16, 0)9663 -1 this.cache = Buffer.allocUnsafe(0)9664 -1 }9665 -19666 -1 // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html9667 -1 // by Juho Vähä-Herttua9668 -1 GHASH.prototype.ghash = function (block) {9669 -1 var i = -19670 -1 while (++i < block.length) {9671 -1 this.state[i] ^= block[i]9672 -1 }9673 -1 this._multiply()9674 -1 }9675 -19676 -1 GHASH.prototype._multiply = function () {9677 -1 var Vi = toArray(this.h)9678 -1 var Zi = [0, 0, 0, 0]9679 -1 var j, xi, lsbVi9680 -1 var i = -19681 -1 while (++i < 128) {9682 -1 xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 09683 -1 if (xi) {9684 -1 // Z_i+1 = Z_i ^ V_i9685 -1 Zi[0] ^= Vi[0]9686 -1 Zi[1] ^= Vi[1]9687 -1 Zi[2] ^= Vi[2]9688 -1 Zi[3] ^= Vi[3]9689 -1 }9690 -19691 -1 // Store the value of LSB(V_i)9692 -1 lsbVi = (Vi[3] & 1) !== 09693 -19694 -1 // V_i+1 = V_i >> 19695 -1 for (j = 3; j > 0; j--) {9696 -1 Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31)9697 -1 }9698 -1 Vi[0] = Vi[0] >>> 19699 -19700 -1 // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R9701 -1 if (lsbVi) {9702 -1 Vi[0] = Vi[0] ^ (0xe1 << 24)9703 -1 }9704 -1 }9705 -1 this.state = fromArray(Zi)9706 -1 }9707 -19708 -1 GHASH.prototype.update = function (buf) {9709 -1 this.cache = Buffer.concat([this.cache, buf])9710 -1 var chunk9711 -1 while (this.cache.length >= 16) {9712 -1 chunk = this.cache.slice(0, 16)9713 -1 this.cache = this.cache.slice(16)9714 -1 this.ghash(chunk)9715 -1 }9716 -1 }9717 -19718 -1 GHASH.prototype.final = function (abl, bl) {9719 -1 if (this.cache.length) {9720 -1 this.ghash(Buffer.concat([this.cache, ZEROES], 16))9721 -1 }9722 -19723 -1 this.ghash(fromArray([0, abl, 0, bl]))9724 -1 return this.state9725 -1 }9726 -19727 -1 module.exports = GHASH9728 -19729 -1 },{"safe-buffer":160}],26:[function(require,module,exports){9730 -1 function incr32 (iv) {9731 -1 var len = iv.length9732 -1 var item9733 -1 while (len--) {9734 -1 item = iv.readUInt8(len)9735 -1 if (item === 255) {9736 -1 iv.writeUInt8(0, len)9737 -1 } else {9738 -1 item++9739 -1 iv.writeUInt8(item, len)9740 -1 break9741 -1 }9742 -1 }9743 -1 }9744 -1 module.exports = incr329745 -19746 -1 },{}],27:[function(require,module,exports){9747 -1 var xor = require('buffer-xor')9748 -19749 -1 exports.encrypt = function (self, block) {9750 -1 var data = xor(block, self._prev)9751 -19752 -1 self._prev = self._cipher.encryptBlock(data)9753 -1 return self._prev9754 -1 }9755 -19756 -1 exports.decrypt = function (self, block) {9757 -1 var pad = self._prev9758 -19759 -1 self._prev = block9760 -1 var out = self._cipher.decryptBlock(block)9761 -19762 -1 return xor(out, pad)9763 -1 }9764 -19765 -1 },{"buffer-xor":62}],28:[function(require,module,exports){9766 -1 var Buffer = require('safe-buffer').Buffer9767 -1 var xor = require('buffer-xor')9768 -19769 -1 function encryptStart (self, data, decrypt) {9770 -1 var len = data.length9771 -1 var out = xor(data, self._cache)9772 -1 self._cache = self._cache.slice(len)9773 -1 self._prev = Buffer.concat([self._prev, decrypt ? data : out])9774 -1 return out9775 -1 }9776 -19777 -1 exports.encrypt = function (self, data, decrypt) {9778 -1 var out = Buffer.allocUnsafe(0)9779 -1 var len9780 -19781 -1 while (data.length) {9782 -1 if (self._cache.length === 0) {9783 -1 self._cache = self._cipher.encryptBlock(self._prev)9784 -1 self._prev = Buffer.allocUnsafe(0)9785 -1 }9786 -19787 -1 if (self._cache.length <= data.length) {9788 -1 len = self._cache.length9789 -1 out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)])9790 -1 data = data.slice(len)9791 -1 } else {9792 -1 out = Buffer.concat([out, encryptStart(self, data, decrypt)])9793 -1 break9794 -1 }9795 -1 }9796 -19797 -1 return out9798 -1 }9799 -19800 -1 },{"buffer-xor":62,"safe-buffer":160}],29:[function(require,module,exports){9801 -1 var Buffer = require('safe-buffer').Buffer9802 -19803 -1 function encryptByte (self, byteParam, decrypt) {9804 -1 var pad9805 -1 var i = -19806 -1 var len = 89807 -1 var out = 09808 -1 var bit, value9809 -1 while (++i < len) {9810 -1 pad = self._cipher.encryptBlock(self._prev)9811 -1 bit = (byteParam & (1 << (7 - i))) ? 0x80 : 09812 -1 value = pad[0] ^ bit9813 -1 out += ((value & 0x80) >> (i % 8))9814 -1 self._prev = shiftIn(self._prev, decrypt ? bit : value)9815 -1 }9816 -1 return out9817 -1 }9818 -19819 -1 function shiftIn (buffer, value) {9820 -1 var len = buffer.length9821 -1 var i = -19822 -1 var out = Buffer.allocUnsafe(buffer.length)9823 -1 buffer = Buffer.concat([buffer, Buffer.from([value])])9824 -19825 -1 while (++i < len) {9826 -1 out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)9827 -1 }9828 -19829 -1 return out9830 -1 }9831 -19832 -1 exports.encrypt = function (self, chunk, decrypt) {9833 -1 var len = chunk.length9834 -1 var out = Buffer.allocUnsafe(len)9835 -1 var i = -19836 -19837 -1 while (++i < len) {9838 -1 out[i] = encryptByte(self, chunk[i], decrypt)9839 -1 }9840 -19841 -1 return out9842 -1 }9843 -19844 -1 },{"safe-buffer":160}],30:[function(require,module,exports){9845 -1 var Buffer = require('safe-buffer').Buffer9846 -19847 -1 function encryptByte (self, byteParam, decrypt) {9848 -1 var pad = self._cipher.encryptBlock(self._prev)9849 -1 var out = pad[0] ^ byteParam9850 -19851 -1 self._prev = Buffer.concat([9852 -1 self._prev.slice(1),9853 -1 Buffer.from([decrypt ? byteParam : out])9854 -1 ])9855 -19856 -1 return out9857 -1 }9858 -19859 -1 exports.encrypt = function (self, chunk, decrypt) {9860 -1 var len = chunk.length9861 -1 var out = Buffer.allocUnsafe(len)9862 -1 var i = -19863 -19864 -1 while (++i < len) {9865 -1 out[i] = encryptByte(self, chunk[i], decrypt)9866 -1 }9867 -19868 -1 return out9869 -1 }9870 -19871 -1 },{"safe-buffer":160}],31:[function(require,module,exports){9872 -1 var xor = require('buffer-xor')9873 -1 var Buffer = require('safe-buffer').Buffer9874 -1 var incr32 = require('../incr32')9875 -19876 -1 function getBlock (self) {9877 -1 var out = self._cipher.encryptBlockRaw(self._prev)9878 -1 incr32(self._prev)9879 -1 return out9880 -1 }9881 -19882 -1 var blockSize = 169883 -1 exports.encrypt = function (self, chunk) {9884 -1 var chunkNum = Math.ceil(chunk.length / blockSize)9885 -1 var start = self._cache.length9886 -1 self._cache = Buffer.concat([9887 -1 self._cache,9888 -1 Buffer.allocUnsafe(chunkNum * blockSize)9889 -1 ])9890 -1 for (var i = 0; i < chunkNum; i++) {9891 -1 var out = getBlock(self)9892 -1 var offset = start + i * blockSize9893 -1 self._cache.writeUInt32BE(out[0], offset + 0)9894 -1 self._cache.writeUInt32BE(out[1], offset + 4)9895 -1 self._cache.writeUInt32BE(out[2], offset + 8)9896 -1 self._cache.writeUInt32BE(out[3], offset + 12)9897 -1 }9898 -1 var pad = self._cache.slice(0, chunk.length)9899 -1 self._cache = self._cache.slice(chunk.length)9900 -1 return xor(chunk, pad)9901 -1 }9902 -19903 -1 },{"../incr32":26,"buffer-xor":62,"safe-buffer":160}],32:[function(require,module,exports){9904 -1 exports.encrypt = function (self, block) {9905 -1 return self._cipher.encryptBlock(block)9906 -1 }9907 -19908 -1 exports.decrypt = function (self, block) {9909 -1 return self._cipher.decryptBlock(block)9910 -1 }9911 -19912 -1 },{}],33:[function(require,module,exports){9913 -1 var modeModules = {9914 -1 ECB: require('./ecb'),9915 -1 CBC: require('./cbc'),9916 -1 CFB: require('./cfb'),9917 -1 CFB8: require('./cfb8'),9918 -1 CFB1: require('./cfb1'),9919 -1 OFB: require('./ofb'),9920 -1 CTR: require('./ctr'),9921 -1 GCM: require('./ctr')9922 -1 }9923 -19924 -1 var modes = require('./list.json')9925 -19926 -1 for (var key in modes) {9927 -1 modes[key].module = modeModules[modes[key].mode]9928 -1 }9929 -19930 -1 module.exports = modes9931 -19932 -1 },{"./cbc":27,"./cfb":28,"./cfb1":29,"./cfb8":30,"./ctr":31,"./ecb":32,"./list.json":34,"./ofb":35}],34:[function(require,module,exports){9933 -1 module.exports={9934 -1 "aes-128-ecb": {9935 -1 "cipher": "AES",9936 -1 "key": 128,9937 -1 "iv": 0,9938 -1 "mode": "ECB",9939 -1 "type": "block"9940 -1 },9941 -1 "aes-192-ecb": {9942 -1 "cipher": "AES",9943 -1 "key": 192,9944 -1 "iv": 0,9945 -1 "mode": "ECB",9946 -1 "type": "block"9947 -1 },9948 -1 "aes-256-ecb": {9949 -1 "cipher": "AES",9950 -1 "key": 256,9951 -1 "iv": 0,9952 -1 "mode": "ECB",9953 -1 "type": "block"9954 -1 },9955 -1 "aes-128-cbc": {9956 -1 "cipher": "AES",9957 -1 "key": 128,9958 -1 "iv": 16,9959 -1 "mode": "CBC",9960 -1 "type": "block"9961 -1 },9962 -1 "aes-192-cbc": {9963 -1 "cipher": "AES",9964 -1 "key": 192,9965 -1 "iv": 16,9966 -1 "mode": "CBC",9967 -1 "type": "block"9968 -1 },9969 -1 "aes-256-cbc": {9970 -1 "cipher": "AES",9971 -1 "key": 256,9972 -1 "iv": 16,9973 -1 "mode": "CBC",9974 -1 "type": "block"9975 -1 },9976 -1 "aes128": {9977 -1 "cipher": "AES",9978 -1 "key": 128,9979 -1 "iv": 16,9980 -1 "mode": "CBC",9981 -1 "type": "block"9982 -1 },9983 -1 "aes192": {9984 -1 "cipher": "AES",9985 -1 "key": 192,9986 -1 "iv": 16,9987 -1 "mode": "CBC",9988 -1 "type": "block"9989 -1 },9990 -1 "aes256": {9991 -1 "cipher": "AES",9992 -1 "key": 256,9993 -1 "iv": 16,9994 -1 "mode": "CBC",9995 -1 "type": "block"9996 -1 },9997 -1 "aes-128-cfb": {9998 -1 "cipher": "AES",9999 -1 "key": 128,10000 -1 "iv": 16,10001 -1 "mode": "CFB",10002 -1 "type": "stream"10003 -1 },10004 -1 "aes-192-cfb": {10005 -1 "cipher": "AES",10006 -1 "key": 192,10007 -1 "iv": 16,10008 -1 "mode": "CFB",10009 -1 "type": "stream"10010 -1 },10011 -1 "aes-256-cfb": {10012 -1 "cipher": "AES",10013 -1 "key": 256,10014 -1 "iv": 16,10015 -1 "mode": "CFB",10016 -1 "type": "stream"10017 -1 },10018 -1 "aes-128-cfb8": {10019 -1 "cipher": "AES",10020 -1 "key": 128,10021 -1 "iv": 16,10022 -1 "mode": "CFB8",10023 -1 "type": "stream"10024 -1 },10025 -1 "aes-192-cfb8": {10026 -1 "cipher": "AES",10027 -1 "key": 192,10028 -1 "iv": 16,10029 -1 "mode": "CFB8",10030 -1 "type": "stream"10031 -1 },10032 -1 "aes-256-cfb8": {10033 -1 "cipher": "AES",10034 -1 "key": 256,10035 -1 "iv": 16,10036 -1 "mode": "CFB8",10037 -1 "type": "stream"10038 -1 },10039 -1 "aes-128-cfb1": {10040 -1 "cipher": "AES",10041 -1 "key": 128,10042 -1 "iv": 16,10043 -1 "mode": "CFB1",10044 -1 "type": "stream"10045 -1 },10046 -1 "aes-192-cfb1": {10047 -1 "cipher": "AES",10048 -1 "key": 192,10049 -1 "iv": 16,10050 -1 "mode": "CFB1",10051 -1 "type": "stream"10052 -1 },10053 -1 "aes-256-cfb1": {10054 -1 "cipher": "AES",10055 -1 "key": 256,10056 -1 "iv": 16,10057 -1 "mode": "CFB1",10058 -1 "type": "stream"10059 -1 },10060 -1 "aes-128-ofb": {10061 -1 "cipher": "AES",10062 -1 "key": 128,10063 -1 "iv": 16,10064 -1 "mode": "OFB",10065 -1 "type": "stream"10066 -1 },10067 -1 "aes-192-ofb": {10068 -1 "cipher": "AES",10069 -1 "key": 192,10070 -1 "iv": 16,10071 -1 "mode": "OFB",10072 -1 "type": "stream"10073 -1 },10074 -1 "aes-256-ofb": {10075 -1 "cipher": "AES",10076 -1 "key": 256,10077 -1 "iv": 16,10078 -1 "mode": "OFB",10079 -1 "type": "stream"10080 -1 },10081 -1 "aes-128-ctr": {10082 -1 "cipher": "AES",10083 -1 "key": 128,10084 -1 "iv": 16,10085 -1 "mode": "CTR",10086 -1 "type": "stream"10087 -1 },10088 -1 "aes-192-ctr": {10089 -1 "cipher": "AES",10090 -1 "key": 192,10091 -1 "iv": 16,10092 -1 "mode": "CTR",10093 -1 "type": "stream"10094 -1 },10095 -1 "aes-256-ctr": {10096 -1 "cipher": "AES",10097 -1 "key": 256,10098 -1 "iv": 16,10099 -1 "mode": "CTR",10100 -1 "type": "stream"10101 -1 },10102 -1 "aes-128-gcm": {10103 -1 "cipher": "AES",10104 -1 "key": 128,10105 -1 "iv": 12,10106 -1 "mode": "GCM",10107 -1 "type": "auth"10108 -1 },10109 -1 "aes-192-gcm": {10110 -1 "cipher": "AES",10111 -1 "key": 192,10112 -1 "iv": 12,10113 -1 "mode": "GCM",10114 -1 "type": "auth"10115 -1 },10116 -1 "aes-256-gcm": {10117 -1 "cipher": "AES",10118 -1 "key": 256,10119 -1 "iv": 12,10120 -1 "mode": "GCM",10121 -1 "type": "auth"10122 -1 }10123 -1 }10124 -110125 -1 },{}],35:[function(require,module,exports){10126 -1 (function (Buffer){(function (){10127 -1 var xor = require('buffer-xor')10128 -110129 -1 function getBlock (self) {10130 -1 self._prev = self._cipher.encryptBlock(self._prev)10131 -1 return self._prev10132 -1 }10133 -110134 -1 exports.encrypt = function (self, chunk) {10135 -1 while (self._cache.length < chunk.length) {10136 -1 self._cache = Buffer.concat([self._cache, getBlock(self)])10137 -1 }10138 -110139 -1 var pad = self._cache.slice(0, chunk.length)10140 -1 self._cache = self._cache.slice(chunk.length)10141 -1 return xor(chunk, pad)10142 -1 }10143 -110144 -1 }).call(this)}).call(this,require("buffer").Buffer)10145 -1 },{"buffer":63,"buffer-xor":62}],36:[function(require,module,exports){10146 -1 var aes = require('./aes')10147 -1 var Buffer = require('safe-buffer').Buffer10148 -1 var Transform = require('cipher-base')10149 -1 var inherits = require('inherits')10150 -110151 -1 function StreamCipher (mode, key, iv, decrypt) {10152 -1 Transform.call(this)10153 -110154 -1 this._cipher = new aes.AES(key)10155 -1 this._prev = Buffer.from(iv)10156 -1 this._cache = Buffer.allocUnsafe(0)10157 -1 this._secCache = Buffer.allocUnsafe(0)10158 -1 this._decrypt = decrypt10159 -1 this._mode = mode10160 -1 }10161 -110162 -1 inherits(StreamCipher, Transform)10163 -110164 -1 StreamCipher.prototype._update = function (chunk) {10165 -1 return this._mode.encrypt(this, chunk, this._decrypt)10166 -1 }10167 -110168 -1 StreamCipher.prototype._final = function () {10169 -1 this._cipher.scrub()10170 -1 }10171 -110172 -1 module.exports = StreamCipher10173 -110174 -1 },{"./aes":20,"cipher-base":64,"inherits":132,"safe-buffer":160}],37:[function(require,module,exports){10175 -1 var DES = require('browserify-des')10176 -1 var aes = require('browserify-aes/browser')10177 -1 var aesModes = require('browserify-aes/modes')10178 -1 var desModes = require('browserify-des/modes')10179 -1 var ebtk = require('evp_bytestokey')10180 -110181 -1 function createCipher (suite, password) {10182 -1 suite = suite.toLowerCase()10183 -110184 -1 var keyLen, ivLen10185 -1 if (aesModes[suite]) {10186 -1 keyLen = aesModes[suite].key10187 -1 ivLen = aesModes[suite].iv10188 -1 } else if (desModes[suite]) {10189 -1 keyLen = desModes[suite].key * 810190 -1 ivLen = desModes[suite].iv10191 -1 } else {10192 -1 throw new TypeError('invalid suite type')10193 -1 }10194 -110195 -1 var keys = ebtk(password, false, keyLen, ivLen)10196 -1 return createCipheriv(suite, keys.key, keys.iv)10197 -1 }10198 -110199 -1 function createDecipher (suite, password) {10200 -1 suite = suite.toLowerCase()10201 -110202 -1 var keyLen, ivLen10203 -1 if (aesModes[suite]) {10204 -1 keyLen = aesModes[suite].key10205 -1 ivLen = aesModes[suite].iv10206 -1 } else if (desModes[suite]) {10207 -1 keyLen = desModes[suite].key * 810208 -1 ivLen = desModes[suite].iv10209 -1 } else {10210 -1 throw new TypeError('invalid suite type')10211 -1 }10212 -110213 -1 var keys = ebtk(password, false, keyLen, ivLen)10214 -1 return createDecipheriv(suite, keys.key, keys.iv)10215 -1 }10216 -110217 -1 function createCipheriv (suite, key, iv) {10218 -1 suite = suite.toLowerCase()10219 -1 if (aesModes[suite]) return aes.createCipheriv(suite, key, iv)10220 -1 if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite })10221 -110222 -1 throw new TypeError('invalid suite type')10223 -1 }10224 -110225 -1 function createDecipheriv (suite, key, iv) {10226 -1 suite = suite.toLowerCase()10227 -1 if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv)10228 -1 if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite, decrypt: true })10229 -110230 -1 throw new TypeError('invalid suite type')10231 -1 }10232 -110233 -1 function getCiphers () {10234 -1 return Object.keys(desModes).concat(aes.getCiphers())10235 -1 }10236 -110237 -1 exports.createCipher = exports.Cipher = createCipher10238 -1 exports.createCipheriv = exports.Cipheriv = createCipheriv10239 -1 exports.createDecipher = exports.Decipher = createDecipher10240 -1 exports.createDecipheriv = exports.Decipheriv = createDecipheriv10241 -1 exports.listCiphers = exports.getCiphers = getCiphers10242 -110243 -1 },{"browserify-aes/browser":22,"browserify-aes/modes":33,"browserify-des":38,"browserify-des/modes":39,"evp_bytestokey":101}],38:[function(require,module,exports){10244 -1 var CipherBase = require('cipher-base')10245 -1 var des = require('des.js')10246 -1 var inherits = require('inherits')10247 -1 var Buffer = require('safe-buffer').Buffer10248 -110249 -1 var modes = {10250 -1 'des-ede3-cbc': des.CBC.instantiate(des.EDE),10251 -1 'des-ede3': des.EDE,10252 -1 'des-ede-cbc': des.CBC.instantiate(des.EDE),10253 -1 'des-ede': des.EDE,10254 -1 'des-cbc': des.CBC.instantiate(des.DES),10255 -1 'des-ecb': des.DES10256 -1 }10257 -1 modes.des = modes['des-cbc']10258 -1 modes.des3 = modes['des-ede3-cbc']10259 -1 module.exports = DES10260 -1 inherits(DES, CipherBase)10261 -1 function DES (opts) {10262 -1 CipherBase.call(this)10263 -1 var modeName = opts.mode.toLowerCase()10264 -1 var mode = modes[modeName]10265 -1 var type10266 -1 if (opts.decrypt) {10267 -1 type = 'decrypt'10268 -1 } else {10269 -1 type = 'encrypt'10270 -1 }10271 -1 var key = opts.key10272 -1 if (!Buffer.isBuffer(key)) {10273 -1 key = Buffer.from(key)10274 -1 }10275 -1 if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {10276 -1 key = Buffer.concat([key, key.slice(0, 8)])10277 -1 }10278 -1 var iv = opts.iv10279 -1 if (!Buffer.isBuffer(iv)) {10280 -1 iv = Buffer.from(iv)10281 -1 }10282 -1 this._des = mode.create({10283 -1 key: key,10284 -1 iv: iv,10285 -1 type: type10286 -1 })10287 -1 }10288 -1 DES.prototype._update = function (data) {10289 -1 return Buffer.from(this._des.update(data))10290 -1 }10291 -1 DES.prototype._final = function () {10292 -1 return Buffer.from(this._des.final())10293 -1 }10294 -110295 -1 },{"cipher-base":64,"des.js":72,"inherits":132,"safe-buffer":160}],39:[function(require,module,exports){10296 -1 exports['des-ecb'] = {10297 -1 key: 8,10298 -1 iv: 010299 -1 }10300 -1 exports['des-cbc'] = exports.des = {10301 -1 key: 8,10302 -1 iv: 810303 -1 }10304 -1 exports['des-ede3-cbc'] = exports.des3 = {10305 -1 key: 24,10306 -1 iv: 810307 -1 }10308 -1 exports['des-ede3'] = {10309 -1 key: 24,10310 -1 iv: 010311 -1 }10312 -1 exports['des-ede-cbc'] = {10313 -1 key: 16,10314 -1 iv: 810315 -1 }10316 -1 exports['des-ede'] = {10317 -1 key: 16,10318 -1 iv: 010319 -1 }10320 -110321 -1 },{}],40:[function(require,module,exports){10322 -1 (function (Buffer){(function (){10323 -1 var BN = require('bn.js')10324 -1 var randomBytes = require('randombytes')10325 -110326 -1 function blind (priv) {10327 -1 var r = getr(priv)10328 -1 var blinder = r.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed()10329 -1 return { blinder: blinder, unblinder: r.invm(priv.modulus) }10330 -1 }10331 -110332 -1 function getr (priv) {10333 -1 var len = priv.modulus.byteLength()10334 -1 var r10335 -1 do {10336 -1 r = new BN(randomBytes(len))10337 -1 } while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2))10338 -1 return r10339 -1 }10340 -110341 -1 function crt (msg, priv) {10342 -1 var blinds = blind(priv)10343 -1 var len = priv.modulus.byteLength()10344 -1 var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus)10345 -1 var c1 = blinded.toRed(BN.mont(priv.prime1))10346 -1 var c2 = blinded.toRed(BN.mont(priv.prime2))10347 -1 var qinv = priv.coefficient10348 -1 var p = priv.prime110349 -1 var q = priv.prime210350 -1 var m1 = c1.redPow(priv.exponent1).fromRed()10351 -1 var m2 = c2.redPow(priv.exponent2).fromRed()10352 -1 var h = m1.isub(m2).imul(qinv).umod(p).imul(q)10353 -1 return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer, 'be', len)10354 -1 }10355 -1 crt.getr = getr10356 -110357 -1 module.exports = crt10358 -110359 -1 }).call(this)}).call(this,require("buffer").Buffer)10360 -1 },{"bn.js":17,"buffer":63,"randombytes":157}],41:[function(require,module,exports){10361 -1 module.exports = require('./browser/algorithms.json')10362 -110363 -1 },{"./browser/algorithms.json":42}],42:[function(require,module,exports){10364 -1 module.exports={10365 -1 "sha224WithRSAEncryption": {10366 -1 "sign": "rsa",10367 -1 "hash": "sha224",10368 -1 "id": "302d300d06096086480165030402040500041c"10369 -1 },10370 -1 "RSA-SHA224": {10371 -1 "sign": "ecdsa/rsa",10372 -1 "hash": "sha224",10373 -1 "id": "302d300d06096086480165030402040500041c"10374 -1 },10375 -1 "sha256WithRSAEncryption": {10376 -1 "sign": "rsa",10377 -1 "hash": "sha256",10378 -1 "id": "3031300d060960864801650304020105000420"10379 -1 },10380 -1 "RSA-SHA256": {10381 -1 "sign": "ecdsa/rsa",10382 -1 "hash": "sha256",10383 -1 "id": "3031300d060960864801650304020105000420"10384 -1 },10385 -1 "sha384WithRSAEncryption": {10386 -1 "sign": "rsa",10387 -1 "hash": "sha384",10388 -1 "id": "3041300d060960864801650304020205000430"10389 -1 },10390 -1 "RSA-SHA384": {10391 -1 "sign": "ecdsa/rsa",10392 -1 "hash": "sha384",10393 -1 "id": "3041300d060960864801650304020205000430"10394 -1 },10395 -1 "sha512WithRSAEncryption": {10396 -1 "sign": "rsa",10397 -1 "hash": "sha512",10398 -1 "id": "3051300d060960864801650304020305000440"10399 -1 },10400 -1 "RSA-SHA512": {10401 -1 "sign": "ecdsa/rsa",10402 -1 "hash": "sha512",10403 -1 "id": "3051300d060960864801650304020305000440"10404 -1 },10405 -1 "RSA-SHA1": {10406 -1 "sign": "rsa",10407 -1 "hash": "sha1",10408 -1 "id": "3021300906052b0e03021a05000414"10409 -1 },10410 -1 "ecdsa-with-SHA1": {10411 -1 "sign": "ecdsa",10412 -1 "hash": "sha1",10413 -1 "id": ""10414 -1 },10415 -1 "sha256": {10416 -1 "sign": "ecdsa",10417 -1 "hash": "sha256",10418 -1 "id": ""10419 -1 },10420 -1 "sha224": {10421 -1 "sign": "ecdsa",10422 -1 "hash": "sha224",10423 -1 "id": ""10424 -1 },10425 -1 "sha384": {10426 -1 "sign": "ecdsa",10427 -1 "hash": "sha384",10428 -1 "id": ""10429 -1 },10430 -1 "sha512": {10431 -1 "sign": "ecdsa",10432 -1 "hash": "sha512",10433 -1 "id": ""10434 -1 },10435 -1 "DSA-SHA": {10436 -1 "sign": "dsa",10437 -1 "hash": "sha1",10438 -1 "id": ""10439 -1 },10440 -1 "DSA-SHA1": {10441 -1 "sign": "dsa",10442 -1 "hash": "sha1",10443 -1 "id": ""10444 -1 },10445 -1 "DSA": {10446 -1 "sign": "dsa",10447 -1 "hash": "sha1",10448 -1 "id": ""10449 -1 },10450 -1 "DSA-WITH-SHA224": {10451 -1 "sign": "dsa",10452 -1 "hash": "sha224",10453 -1 "id": ""10454 -1 },10455 -1 "DSA-SHA224": {10456 -1 "sign": "dsa",10457 -1 "hash": "sha224",10458 -1 "id": ""10459 -1 },10460 -1 "DSA-WITH-SHA256": {10461 -1 "sign": "dsa",10462 -1 "hash": "sha256",10463 -1 "id": ""10464 -1 },10465 -1 "DSA-SHA256": {10466 -1 "sign": "dsa",10467 -1 "hash": "sha256",10468 -1 "id": ""10469 -1 },10470 -1 "DSA-WITH-SHA384": {10471 -1 "sign": "dsa",10472 -1 "hash": "sha384",10473 -1 "id": ""10474 -1 },10475 -1 "DSA-SHA384": {10476 -1 "sign": "dsa",10477 -1 "hash": "sha384",10478 -1 "id": ""10479 -1 },10480 -1 "DSA-WITH-SHA512": {10481 -1 "sign": "dsa",10482 -1 "hash": "sha512",10483 -1 "id": ""10484 -1 },10485 -1 "DSA-SHA512": {10486 -1 "sign": "dsa",10487 -1 "hash": "sha512",10488 -1 "id": ""10489 -1 },10490 -1 "DSA-RIPEMD160": {10491 -1 "sign": "dsa",10492 -1 "hash": "rmd160",10493 -1 "id": ""10494 -1 },10495 -1 "ripemd160WithRSA": {10496 -1 "sign": "rsa",10497 -1 "hash": "rmd160",10498 -1 "id": "3021300906052b2403020105000414"10499 -1 },10500 -1 "RSA-RIPEMD160": {10501 -1 "sign": "rsa",10502 -1 "hash": "rmd160",10503 -1 "id": "3021300906052b2403020105000414"10504 -1 },10505 -1 "md5WithRSAEncryption": {10506 -1 "sign": "rsa",10507 -1 "hash": "md5",10508 -1 "id": "3020300c06082a864886f70d020505000410"10509 -1 },10510 -1 "RSA-MD5": {10511 -1 "sign": "rsa",10512 -1 "hash": "md5",10513 -1 "id": "3020300c06082a864886f70d020505000410"10514 -1 }10515 -1 }10516 -110517 -1 },{}],43:[function(require,module,exports){10518 -1 module.exports={10519 -1 "1.3.132.0.10": "secp256k1",10520 -1 "1.3.132.0.33": "p224",10521 -1 "1.2.840.10045.3.1.1": "p192",10522 -1 "1.2.840.10045.3.1.7": "p256",10523 -1 "1.3.132.0.34": "p384",10524 -1 "1.3.132.0.35": "p521"10525 -1 }10526 -110527 -1 },{}],44:[function(require,module,exports){10528 -1 var Buffer = require('safe-buffer').Buffer10529 -1 var createHash = require('create-hash')10530 -1 var stream = require('readable-stream')10531 -1 var inherits = require('inherits')10532 -1 var sign = require('./sign')10533 -1 var verify = require('./verify')10534 -110535 -1 var algorithms = require('./algorithms.json')10536 -1 Object.keys(algorithms).forEach(function (key) {10537 -1 algorithms[key].id = Buffer.from(algorithms[key].id, 'hex')10538 -1 algorithms[key.toLowerCase()] = algorithms[key]10539 -1 })10540 -110541 -1 function Sign (algorithm) {10542 -1 stream.Writable.call(this)10543 -110544 -1 var data = algorithms[algorithm]10545 -1 if (!data) throw new Error('Unknown message digest')10546 -110547 -1 this._hashType = data.hash10548 -1 this._hash = createHash(data.hash)10549 -1 this._tag = data.id10550 -1 this._signType = data.sign10551 -1 }10552 -1 inherits(Sign, stream.Writable)10553 -110554 -1 Sign.prototype._write = function _write (data, _, done) {10555 -1 this._hash.update(data)10556 -1 done()10557 -1 }10558 -110559 -1 Sign.prototype.update = function update (data, enc) {10560 -1 if (typeof data === 'string') data = Buffer.from(data, enc)10561 -110562 -1 this._hash.update(data)10563 -1 return this10564 -1 }10565 -110566 -1 Sign.prototype.sign = function signMethod (key, enc) {10567 -1 this.end()10568 -1 var hash = this._hash.digest()10569 -1 var sig = sign(hash, key, this._hashType, this._signType, this._tag)10570 -110571 -1 return enc ? sig.toString(enc) : sig10572 -1 }10573 -110574 -1 function Verify (algorithm) {10575 -1 stream.Writable.call(this)10576 -110577 -1 var data = algorithms[algorithm]10578 -1 if (!data) throw new Error('Unknown message digest')10579 -110580 -1 this._hash = createHash(data.hash)10581 -1 this._tag = data.id10582 -1 this._signType = data.sign10583 -1 }10584 -1 inherits(Verify, stream.Writable)10585 -110586 -1 Verify.prototype._write = function _write (data, _, done) {10587 -1 this._hash.update(data)10588 -1 done()10589 -1 }10590 -110591 -1 Verify.prototype.update = function update (data, enc) {10592 -1 if (typeof data === 'string') data = Buffer.from(data, enc)10593 -110594 -1 this._hash.update(data)10595 -1 return this10596 -1 }10597 -110598 -1 Verify.prototype.verify = function verifyMethod (key, sig, enc) {10599 -1 if (typeof sig === 'string') sig = Buffer.from(sig, enc)10600 -110601 -1 this.end()10602 -1 var hash = this._hash.digest()10603 -1 return verify(sig, hash, key, this._signType, this._tag)10604 -1 }10605 -110606 -1 function createSign (algorithm) {10607 -1 return new Sign(algorithm)10608 -1 }10609 -110610 -1 function createVerify (algorithm) {10611 -1 return new Verify(algorithm)10612 -1 }10613 -110614 -1 module.exports = {10615 -1 Sign: createSign,10616 -1 Verify: createVerify,10617 -1 createSign: createSign,10618 -1 createVerify: createVerify10619 -1 }10620 -110621 -1 },{"./algorithms.json":42,"./sign":45,"./verify":46,"create-hash":67,"inherits":132,"readable-stream":61,"safe-buffer":160}],45:[function(require,module,exports){10622 -1 // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js10623 -1 var Buffer = require('safe-buffer').Buffer10624 -1 var createHmac = require('create-hmac')10625 -1 var crt = require('browserify-rsa')10626 -1 var EC = require('elliptic').ec10627 -1 var BN = require('bn.js')10628 -1 var parseKeys = require('parse-asn1')10629 -1 var curves = require('./curves.json')10630 -110631 -1 function sign (hash, key, hashType, signType, tag) {10632 -1 var priv = parseKeys(key)10633 -1 if (priv.curve) {10634 -1 // rsa keys can be interpreted as ecdsa ones in openssl10635 -1 if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')10636 -1 return ecSign(hash, priv)10637 -1 } else if (priv.type === 'dsa') {10638 -1 if (signType !== 'dsa') throw new Error('wrong private key type')10639 -1 return dsaSign(hash, priv, hashType)10640 -1 } else {10641 -1 if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')10642 -1 }10643 -1 hash = Buffer.concat([tag, hash])10644 -1 var len = priv.modulus.byteLength()10645 -1 var pad = [0, 1]10646 -1 while (hash.length + pad.length + 1 < len) pad.push(0xff)10647 -1 pad.push(0x00)10648 -1 var i = -110649 -1 while (++i < hash.length) pad.push(hash[i])10650 -110651 -1 var out = crt(pad, priv)10652 -1 return out10653 -1 }10654 -110655 -1 function ecSign (hash, priv) {10656 -1 var curveId = curves[priv.curve.join('.')]10657 -1 if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'))10658 -110659 -1 var curve = new EC(curveId)10660 -1 var key = curve.keyFromPrivate(priv.privateKey)10661 -1 var out = key.sign(hash)10662 -110663 -1 return Buffer.from(out.toDER())10664 -1 }10665 -110666 -1 function dsaSign (hash, priv, algo) {10667 -1 var x = priv.params.priv_key10668 -1 var p = priv.params.p10669 -1 var q = priv.params.q10670 -1 var g = priv.params.g10671 -1 var r = new BN(0)10672 -1 var k10673 -1 var H = bits2int(hash, q).mod(q)10674 -1 var s = false10675 -1 var kv = getKey(x, q, hash, algo)10676 -1 while (s === false) {10677 -1 k = makeKey(q, kv, algo)10678 -1 r = makeR(g, k, p, q)10679 -1 s = k.invm(q).imul(H.add(x.mul(r))).mod(q)10680 -1 if (s.cmpn(0) === 0) {10681 -1 s = false10682 -1 r = new BN(0)10683 -1 }10684 -1 }10685 -1 return toDER(r, s)10686 -1 }10687 -110688 -1 function toDER (r, s) {10689 -1 r = r.toArray()10690 -1 s = s.toArray()10691 -110692 -1 // Pad values10693 -1 if (r[0] & 0x80) r = [0].concat(r)10694 -1 if (s[0] & 0x80) s = [0].concat(s)10695 -110696 -1 var total = r.length + s.length + 410697 -1 var res = [0x30, total, 0x02, r.length]10698 -1 res = res.concat(r, [0x02, s.length], s)10699 -1 return Buffer.from(res)10700 -1 }10701 -110702 -1 function getKey (x, q, hash, algo) {10703 -1 x = Buffer.from(x.toArray())10704 -1 if (x.length < q.byteLength()) {10705 -1 var zeros = Buffer.alloc(q.byteLength() - x.length)10706 -1 x = Buffer.concat([zeros, x])10707 -1 }10708 -1 var hlen = hash.length10709 -1 var hbits = bits2octets(hash, q)10710 -1 var v = Buffer.alloc(hlen)10711 -1 v.fill(1)10712 -1 var k = Buffer.alloc(hlen)10713 -1 k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest()10714 -1 v = createHmac(algo, k).update(v).digest()10715 -1 k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest()10716 -1 v = createHmac(algo, k).update(v).digest()10717 -1 return { k: k, v: v }10718 -1 }10719 -110720 -1 function bits2int (obits, q) {10721 -1 var bits = new BN(obits)10722 -1 var shift = (obits.length << 3) - q.bitLength()10723 -1 if (shift > 0) bits.ishrn(shift)10724 -1 return bits10725 -1 }10726 -110727 -1 function bits2octets (bits, q) {10728 -1 bits = bits2int(bits, q)10729 -1 bits = bits.mod(q)10730 -1 var out = Buffer.from(bits.toArray())10731 -1 if (out.length < q.byteLength()) {10732 -1 var zeros = Buffer.alloc(q.byteLength() - out.length)10733 -1 out = Buffer.concat([zeros, out])10734 -1 }10735 -1 return out10736 -1 }10737 -110738 -1 function makeKey (q, kv, algo) {10739 -1 var t10740 -1 var k10741 -110742 -1 do {10743 -1 t = Buffer.alloc(0)10744 -110745 -1 while (t.length * 8 < q.bitLength()) {10746 -1 kv.v = createHmac(algo, kv.k).update(kv.v).digest()10747 -1 t = Buffer.concat([t, kv.v])10748 -1 }10749 -110750 -1 k = bits2int(t, q)10751 -1 kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest()10752 -1 kv.v = createHmac(algo, kv.k).update(kv.v).digest()10753 -1 } while (k.cmp(q) !== -1)10754 -110755 -1 return k10756 -1 }10757 -110758 -1 function makeR (g, k, p, q) {10759 -1 return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)10760 -1 }10761 -110762 -1 module.exports = sign10763 -1 module.exports.getKey = getKey10764 -1 module.exports.makeKey = makeKey10765 -110766 -1 },{"./curves.json":43,"bn.js":17,"browserify-rsa":40,"create-hmac":69,"elliptic":83,"parse-asn1":142,"safe-buffer":160}],46:[function(require,module,exports){10767 -1 // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js10768 -1 var Buffer = require('safe-buffer').Buffer10769 -1 var BN = require('bn.js')10770 -1 var EC = require('elliptic').ec10771 -1 var parseKeys = require('parse-asn1')10772 -1 var curves = require('./curves.json')10773 -110774 -1 function verify (sig, hash, key, signType, tag) {10775 -1 var pub = parseKeys(key)10776 -1 if (pub.type === 'ec') {10777 -1 // rsa keys can be interpreted as ecdsa ones in openssl10778 -1 if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')10779 -1 return ecVerify(sig, hash, pub)10780 -1 } else if (pub.type === 'dsa') {10781 -1 if (signType !== 'dsa') throw new Error('wrong public key type')10782 -1 return dsaVerify(sig, hash, pub)10783 -1 } else {10784 -1 if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')10785 -1 }10786 -1 hash = Buffer.concat([tag, hash])10787 -1 var len = pub.modulus.byteLength()10788 -1 var pad = [1]10789 -1 var padNum = 010790 -1 while (hash.length + pad.length + 2 < len) {10791 -1 pad.push(0xff)10792 -1 padNum++10793 -1 }10794 -1 pad.push(0x00)10795 -1 var i = -110796 -1 while (++i < hash.length) {10797 -1 pad.push(hash[i])10798 -1 }10799 -1 pad = Buffer.from(pad)10800 -1 var red = BN.mont(pub.modulus)10801 -1 sig = new BN(sig).toRed(red)10802 -110803 -1 sig = sig.redPow(new BN(pub.publicExponent))10804 -1 sig = Buffer.from(sig.fromRed().toArray())10805 -1 var out = padNum < 8 ? 1 : 010806 -1 len = Math.min(sig.length, pad.length)10807 -1 if (sig.length !== pad.length) out = 110808 -110809 -1 i = -110810 -1 while (++i < len) out |= sig[i] ^ pad[i]10811 -1 return out === 010812 -1 }10813 -110814 -1 function ecVerify (sig, hash, pub) {10815 -1 var curveId = curves[pub.data.algorithm.curve.join('.')]10816 -1 if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'))10817 -110818 -1 var curve = new EC(curveId)10819 -1 var pubkey = pub.data.subjectPrivateKey.data10820 -110821 -1 return curve.verify(hash, sig, pubkey)10822 -1 }10823 -110824 -1 function dsaVerify (sig, hash, pub) {10825 -1 var p = pub.data.p10826 -1 var q = pub.data.q10827 -1 var g = pub.data.g10828 -1 var y = pub.data.pub_key10829 -1 var unpacked = parseKeys.signature.decode(sig, 'der')10830 -1 var s = unpacked.s10831 -1 var r = unpacked.r10832 -1 checkValue(s, q)10833 -1 checkValue(r, q)10834 -1 var montp = BN.mont(p)10835 -1 var w = s.invm(q)10836 -1 var v = g.toRed(montp)10837 -1 .redPow(new BN(hash).mul(w).mod(q))10838 -1 .fromRed()10839 -1 .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed())10840 -1 .mod(p)10841 -1 .mod(q)10842 -1 return v.cmp(r) === 010843 -1 }10844 -110845 -1 function checkValue (b, q) {10846 -1 if (b.cmpn(0) <= 0) throw new Error('invalid sig')10847 -1 if (b.cmp(q) >= q) throw new Error('invalid sig')10848 -1 }10849 -110850 -1 module.exports = verify10851 -110852 -1 },{"./curves.json":43,"bn.js":17,"elliptic":83,"parse-asn1":142,"safe-buffer":160}],47:[function(require,module,exports){10853 -1 'use strict';10854 -110855 -1 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }10856 -110857 -1 var codes = {};10858 -110859 -1 function createErrorType(code, message, Base) {10860 -1 if (!Base) {10861 -1 Base = Error;10862 -1 }10863 -110864 -1 function getMessage(arg1, arg2, arg3) {10865 -1 if (typeof message === 'string') {10866 -1 return message;10867 -1 } else {10868 -1 return message(arg1, arg2, arg3);10869 -1 }10870 -1 }10871 -110872 -1 var NodeError =10873 -1 /*#__PURE__*/10874 -1 function (_Base) {10875 -1 _inheritsLoose(NodeError, _Base);10876 -110877 -1 function NodeError(arg1, arg2, arg3) {10878 -1 return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;10879 -1 }10880 -110881 -1 return NodeError;10882 -1 }(Base);10883 -110884 -1 NodeError.prototype.name = Base.name;10885 -1 NodeError.prototype.code = code;10886 -1 codes[code] = NodeError;10887 -1 } // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js10888 -110889 -110890 -1 function oneOf(expected, thing) {10891 -1 if (Array.isArray(expected)) {10892 -1 var len = expected.length;10893 -1 expected = expected.map(function (i) {10894 -1 return String(i);10895 -1 });10896 -110897 -1 if (len > 2) {10898 -1 return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];10899 -1 } else if (len === 2) {10900 -1 return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);10901 -1 } else {10902 -1 return "of ".concat(thing, " ").concat(expected[0]);10903 -1 }10904 -1 } else {10905 -1 return "of ".concat(thing, " ").concat(String(expected));10906 -1 }10907 -1 } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith10908 -110909 -110910 -1 function startsWith(str, search, pos) {10911 -1 return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;10912 -1 } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith10913 -110914 -110915 -1 function endsWith(str, search, this_len) {10916 -1 if (this_len === undefined || this_len > str.length) {10917 -1 this_len = str.length;10918 -1 }10919 -110920 -1 return str.substring(this_len - search.length, this_len) === search;10921 -1 } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes10922 -110923 -110924 -1 function includes(str, search, start) {10925 -1 if (typeof start !== 'number') {10926 -1 start = 0;10927 -1 }10928 -110929 -1 if (start + search.length > str.length) {10930 -1 return false;10931 -1 } else {10932 -1 return str.indexOf(search, start) !== -1;10933 -1 }10934 -1 }10935 -110936 -1 createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {10937 -1 return 'The value "' + value + '" is invalid for option "' + name + '"';10938 -1 }, TypeError);10939 -1 createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {10940 -1 // determiner: 'must be' or 'must not be'10941 -1 var determiner;10942 -110943 -1 if (typeof expected === 'string' && startsWith(expected, 'not ')) {10944 -1 determiner = 'must not be';10945 -1 expected = expected.replace(/^not /, '');10946 -1 } else {10947 -1 determiner = 'must be';10948 -1 }10949 -110950 -1 var msg;10951 -110952 -1 if (endsWith(name, ' argument')) {10953 -1 // For cases like 'first argument'10954 -1 msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));10955 -1 } else {10956 -1 var type = includes(name, '.') ? 'property' : 'argument';10957 -1 msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));10958 -1 }10959 -110960 -1 msg += ". Received type ".concat(typeof actual);10961 -1 return msg;10962 -1 }, TypeError);10963 -1 createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');10964 -1 createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {10965 -1 return 'The ' + name + ' method is not implemented';10966 -1 });10967 -1 createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');10968 -1 createErrorType('ERR_STREAM_DESTROYED', function (name) {10969 -1 return 'Cannot call ' + name + ' after a stream was destroyed';10970 -1 });10971 -1 createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');10972 -1 createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');10973 -1 createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');10974 -1 createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);10975 -1 createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {10976 -1 return 'Unknown encoding: ' + arg;10977 -1 }, TypeError);10978 -1 createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');10979 -1 module.exports.codes = codes;10980 -110981 -1 },{}],48:[function(require,module,exports){10982 -1 (function (process){(function (){10983 -1 // Copyright Joyent, Inc. and other Node contributors.10984 -1 //10985 -1 // Permission is hereby granted, free of charge, to any person obtaining a10986 -1 // copy of this software and associated documentation files (the10987 -1 // "Software"), to deal in the Software without restriction, including10988 -1 // without limitation the rights to use, copy, modify, merge, publish,10989 -1 // distribute, sublicense, and/or sell copies of the Software, and to permit10990 -1 // persons to whom the Software is furnished to do so, subject to the10991 -1 // following conditions:10992 -1 //10993 -1 // The above copyright notice and this permission notice shall be included10994 -1 // in all copies or substantial portions of the Software.10995 -1 //10996 -1 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS10997 -1 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF10998 -1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN10999 -1 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,11000 -1 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR11001 -1 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE11002 -1 // USE OR OTHER DEALINGS IN THE SOFTWARE.11003 -1 // a duplex stream is just a stream that is both readable and writable.11004 -1 // Since JS doesn't have multiple prototypal inheritance, this class11005 -1 // prototypally inherits from Readable, and then parasitically from11006 -1 // Writable.11007 -1 'use strict';11008 -1 /*<replacement>*/11009 -111010 -1 var objectKeys = Object.keys || function (obj) {11011 -1 var keys = [];11012 -111013 -1 for (var key in obj) {11014 -1 keys.push(key);11015 -1 }11016 -111017 -1 return keys;11018 -1 };11019 -1 /*</replacement>*/11020 -111021 -111022 -1 module.exports = Duplex;11023 -111024 -1 var Readable = require('./_stream_readable');11025 -111026 -1 var Writable = require('./_stream_writable');11027 -111028 -1 require('inherits')(Duplex, Readable);11029 -111030 -1 {11031 -1 // Allow the keys array to be GC'ed.11032 -1 var keys = objectKeys(Writable.prototype);11033 -111034 -1 for (var v = 0; v < keys.length; v++) {11035 -1 var method = keys[v];11036 -1 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];11037 -1 }11038 -1 }11039 -111040 -1 function Duplex(options) {11041 -1 if (!(this instanceof Duplex)) return new Duplex(options);11042 -1 Readable.call(this, options);11043 -1 Writable.call(this, options);11044 -1 this.allowHalfOpen = true;11045 -111046 -1 if (options) {11047 -1 if (options.readable === false) this.readable = false;11048 -1 if (options.writable === false) this.writable = false;11049 -111050 -1 if (options.allowHalfOpen === false) {11051 -1 this.allowHalfOpen = false;11052 -1 this.once('end', onend);11053 -1 }11054 -1 }11055 -1 }11056 -111057 -1 Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {11058 -1 // making it explicit this property is not enumerable11059 -1 // because otherwise some prototype manipulation in11060 -1 // userland will fail11061 -1 enumerable: false,11062 -1 get: function get() {11063 -1 return this._writableState.highWaterMark;11064 -1 }11065 -1 });11066 -1 Object.defineProperty(Duplex.prototype, 'writableBuffer', {11067 -1 // making it explicit this property is not enumerable11068 -1 // because otherwise some prototype manipulation in11069 -1 // userland will fail11070 -1 enumerable: false,11071 -1 get: function get() {11072 -1 return this._writableState && this._writableState.getBuffer();11073 -1 }11074 -1 });11075 -1 Object.defineProperty(Duplex.prototype, 'writableLength', {11076 -1 // making it explicit this property is not enumerable11077 -1 // because otherwise some prototype manipulation in11078 -1 // userland will fail11079 -1 enumerable: false,11080 -1 get: function get() {11081 -1 return this._writableState.length;11082 -1 }11083 -1 }); // the no-half-open enforcer11084 -111085 -1 function onend() {11086 -1 // If the writable side ended, then we're ok.11087 -1 if (this._writableState.ended) return; // no more data can be written.11088 -1 // But allow more writes to happen in this tick.11089 -111090 -1 process.nextTick(onEndNT, this);11091 -1 }11092 -111093 -1 function onEndNT(self) {11094 -1 self.end();11095 -1 }11096 -111097 -1 Object.defineProperty(Duplex.prototype, 'destroyed', {11098 -1 // making it explicit this property is not enumerable11099 -1 // because otherwise some prototype manipulation in11100 -1 // userland will fail11101 -1 enumerable: false,11102 -1 get: function get() {11103 -1 if (this._readableState === undefined || this._writableState === undefined) {11104 -1 return false;11105 -1 }11106 -111107 -1 return this._readableState.destroyed && this._writableState.destroyed;11108 -1 },11109 -1 set: function set(value) {11110 -1 // we ignore the value if the stream11111 -1 // has not been initialized yet11112 -1 if (this._readableState === undefined || this._writableState === undefined) {11113 -1 return;11114 -1 } // backward compatibility, the user is explicitly11115 -1 // managing destroyed11116 -111117 -111118 -1 this._readableState.destroyed = value;11119 -1 this._writableState.destroyed = value;11120 -1 }11121 -1 });11122 -1 }).call(this)}).call(this,require('_process'))11123 -1 },{"./_stream_readable":50,"./_stream_writable":52,"_process":149,"inherits":132}],49:[function(require,module,exports){11124 -1 // Copyright Joyent, Inc. and other Node contributors.11125 -1 //11126 -1 // Permission is hereby granted, free of charge, to any person obtaining a11127 -1 // copy of this software and associated documentation files (the11128 -1 // "Software"), to deal in the Software without restriction, including11129 -1 // without limitation the rights to use, copy, modify, merge, publish,11130 -1 // distribute, sublicense, and/or sell copies of the Software, and to permit11131 -1 // persons to whom the Software is furnished to do so, subject to the11132 -1 // following conditions:11133 -1 //11134 -1 // The above copyright notice and this permission notice shall be included11135 -1 // in all copies or substantial portions of the Software.11136 -1 //11137 -1 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS11138 -1 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF11139 -1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN11140 -1 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,11141 -1 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR11142 -1 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE11143 -1 // USE OR OTHER DEALINGS IN THE SOFTWARE.11144 -1 // a passthrough stream.11145 -1 // basically just the most minimal sort of Transform stream.11146 -1 // Every written chunk gets output as-is.11147 -1 'use strict';11148 -111149 -1 module.exports = PassThrough;11150 -111151 -1 var Transform = require('./_stream_transform');11152 -111153 -1 require('inherits')(PassThrough, Transform);11154 -111155 -1 function PassThrough(options) {11156 -1 if (!(this instanceof PassThrough)) return new PassThrough(options);11157 -1 Transform.call(this, options);11158 -1 }11159 -111160 -1 PassThrough.prototype._transform = function (chunk, encoding, cb) {11161 -1 cb(null, chunk);11162 -1 };11163 -1 },{"./_stream_transform":51,"inherits":132}],50:[function(require,module,exports){11164 -1 (function (process,global){(function (){11165 -1 // Copyright Joyent, Inc. and other Node contributors.11166 -1 //11167 -1 // Permission is hereby granted, free of charge, to any person obtaining a11168 -1 // copy of this software and associated documentation files (the11169 -1 // "Software"), to deal in the Software without restriction, including11170 -1 // without limitation the rights to use, copy, modify, merge, publish,11171 -1 // distribute, sublicense, and/or sell copies of the Software, and to permit11172 -1 // persons to whom the Software is furnished to do so, subject to the11173 -1 // following conditions:11174 -1 //11175 -1 // The above copyright notice and this permission notice shall be included11176 -1 // in all copies or substantial portions of the Software.11177 -1 //11178 -1 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS11179 -1 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF11180 -1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN11181 -1 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,11182 -1 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR11183 -1 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE11184 -1 // USE OR OTHER DEALINGS IN THE SOFTWARE.11185 -1 'use strict';11186 -111187 -1 module.exports = Readable;11188 -1 /*<replacement>*/11189 -111190 -1 var Duplex;11191 -1 /*</replacement>*/11192 -111193 -1 Readable.ReadableState = ReadableState;11194 -1 /*<replacement>*/11195 -111196 -1 var EE = require('events').EventEmitter;11197 -111198 -1 var EElistenerCount = function EElistenerCount(emitter, type) {11199 -1 return emitter.listeners(type).length;11200 -1 };11201 -1 /*</replacement>*/11202 -111203 -1 /*<replacement>*/11204 -111205 -111206 -1 var Stream = require('./internal/streams/stream');11207 -1 /*</replacement>*/11208 -111209 -111210 -1 var Buffer = require('buffer').Buffer;11211 -111212 -1 var OurUint8Array = global.Uint8Array || function () {};11213 -111214 -1 function _uint8ArrayToBuffer(chunk) {11215 -1 return Buffer.from(chunk);11216 -1 }11217 -111218 -1 function _isUint8Array(obj) {11219 -1 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;11220 -1 }11221 -1 /*<replacement>*/11222 -111223 -111224 -1 var debugUtil = require('util');11225 -111226 -1 var debug;11227 -111228 -1 if (debugUtil && debugUtil.debuglog) {11229 -1 debug = debugUtil.debuglog('stream');11230 -1 } else {11231 -1 debug = function debug() {};11232 -1 }11233 -1 /*</replacement>*/11234 -111235 -111236 -1 var BufferList = require('./internal/streams/buffer_list');11237 -111238 -1 var destroyImpl = require('./internal/streams/destroy');11239 -111240 -1 var _require = require('./internal/streams/state'),11241 -1 getHighWaterMark = _require.getHighWaterMark;11242 -111243 -1 var _require$codes = require('../errors').codes,11244 -1 ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,11245 -1 ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,11246 -1 ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,11247 -1 ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.11248 -111249 -111250 -1 var StringDecoder;11251 -1 var createReadableStreamAsyncIterator;11252 -1 var from;11253 -111254 -1 require('inherits')(Readable, Stream);11255 -111256 -1 var errorOrDestroy = destroyImpl.errorOrDestroy;11257 -1 var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];11258 -111259 -1 function prependListener(emitter, event, fn) {11260 -1 // Sadly this is not cacheable as some libraries bundle their own11261 -1 // event emitter implementation with them.11262 -1 if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any11263 -1 // userland ones. NEVER DO THIS. This is here only because this code needs11264 -1 // to continue to work with older versions of Node.js that do not include11265 -1 // the prependListener() method. The goal is to eventually remove this hack.11266 -111267 -1 if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];11268 -1 }11269 -111270 -1 function ReadableState(options, stream, isDuplex) {11271 -1 Duplex = Duplex || require('./_stream_duplex');11272 -1 options = options || {}; // Duplex streams are both readable and writable, but share11273 -1 // the same options object.11274 -1 // However, some cases require setting options to different11275 -1 // values for the readable and the writable sides of the duplex stream.11276 -1 // These options can be provided separately as readableXXX and writableXXX.11277 -111278 -1 if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to11279 -1 // make all the buffer merging and length checks go away11280 -111281 -1 this.objectMode = !!options.objectMode;11282 -1 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer11283 -1 // Note: 0 is a valid value, means "don't call _read preemptively ever"11284 -111285 -1 this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the11286 -1 // linked list can remove elements from the beginning faster than11287 -1 // array.shift()11288 -111289 -1 this.buffer = new BufferList();11290 -1 this.length = 0;11291 -1 this.pipes = null;11292 -1 this.pipesCount = 0;11293 -1 this.flowing = null;11294 -1 this.ended = false;11295 -1 this.endEmitted = false;11296 -1 this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted11297 -1 // immediately, or on a later tick. We set this to true at first, because11298 -1 // any actions that shouldn't happen until "later" should generally also11299 -1 // not happen before the first read call.11300 -111301 -1 this.sync = true; // whenever we return null, then we set a flag to say11302 -1 // that we're awaiting a 'readable' event emission.11303 -111304 -1 this.needReadable = false;11305 -1 this.emittedReadable = false;11306 -1 this.readableListening = false;11307 -1 this.resumeScheduled = false;11308 -1 this.paused = true; // Should close be emitted on destroy. Defaults to true.11309 -111310 -1 this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')11311 -111312 -1 this.autoDestroy = !!options.autoDestroy; // has it been destroyed11313 -111314 -1 this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string11315 -1 // encoding is 'binary' so we have to make this configurable.11316 -1 // Everything else in the universe uses 'utf8', though.11317 -111318 -1 this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s11319 -111320 -1 this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled11321 -111322 -1 this.readingMore = false;11323 -1 this.decoder = null;11324 -1 this.encoding = null;11325 -111326 -1 if (options.encoding) {11327 -1 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;11328 -1 this.decoder = new StringDecoder(options.encoding);11329 -1 this.encoding = options.encoding;11330 -1 }11331 -1 }11332 -111333 -1 function Readable(options) {11334 -1 Duplex = Duplex || require('./_stream_duplex');11335 -1 if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside11336 -1 // the ReadableState constructor, at least with V8 6.511337 -111338 -1 var isDuplex = this instanceof Duplex;11339 -1 this._readableState = new ReadableState(options, this, isDuplex); // legacy11340 -111341 -1 this.readable = true;11342 -111343 -1 if (options) {11344 -1 if (typeof options.read === 'function') this._read = options.read;11345 -1 if (typeof options.destroy === 'function') this._destroy = options.destroy;11346 -1 }11347 -111348 -1 Stream.call(this);11349 -1 }11350 -111351 -1 Object.defineProperty(Readable.prototype, 'destroyed', {11352 -1 // making it explicit this property is not enumerable11353 -1 // because otherwise some prototype manipulation in11354 -1 // userland will fail11355 -1 enumerable: false,11356 -1 get: function get() {11357 -1 if (this._readableState === undefined) {11358 -1 return false;11359 -1 }11360 -111361 -1 return this._readableState.destroyed;11362 -1 },11363 -1 set: function set(value) {11364 -1 // we ignore the value if the stream11365 -1 // has not been initialized yet11366 -1 if (!this._readableState) {11367 -1 return;11368 -1 } // backward compatibility, the user is explicitly11369 -1 // managing destroyed11370 -111371 -111372 -1 this._readableState.destroyed = value;11373 -1 }11374 -1 });11375 -1 Readable.prototype.destroy = destroyImpl.destroy;11376 -1 Readable.prototype._undestroy = destroyImpl.undestroy;11377 -111378 -1 Readable.prototype._destroy = function (err, cb) {11379 -1 cb(err);11380 -1 }; // Manually shove something into the read() buffer.11381 -1 // This returns true if the highWaterMark has not been hit yet,11382 -1 // similar to how Writable.write() returns true if you should11383 -1 // write() some more.11384 -111385 -111386 -1 Readable.prototype.push = function (chunk, encoding) {11387 -1 var state = this._readableState;11388 -1 var skipChunkCheck;11389 -111390 -1 if (!state.objectMode) {11391 -1 if (typeof chunk === 'string') {11392 -1 encoding = encoding || state.defaultEncoding;11393 -111394 -1 if (encoding !== state.encoding) {11395 -1 chunk = Buffer.from(chunk, encoding);11396 -1 encoding = '';11397 -1 }11398 -111399 -1 skipChunkCheck = true;11400 -1 }11401 -1 } else {11402 -1 skipChunkCheck = true;11403 -1 }11404 -111405 -1 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);11406 -1 }; // Unshift should *always* be something directly out of read()11407 -111408 -111409 -1 Readable.prototype.unshift = function (chunk) {11410 -1 return readableAddChunk(this, chunk, null, true, false);11411 -1 };11412 -111413 -1 function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {11414 -1 debug('readableAddChunk', chunk);11415 -1 var state = stream._readableState;11416 -111417 -1 if (chunk === null) {11418 -1 state.reading = false;11419 -1 onEofChunk(stream, state);11420 -1 } else {11421 -1 var er;11422 -1 if (!skipChunkCheck) er = chunkInvalid(state, chunk);11423 -111424 -1 if (er) {11425 -1 errorOrDestroy(stream, er);11426 -1 } else if (state.objectMode || chunk && chunk.length > 0) {11427 -1 if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {11428 -1 chunk = _uint8ArrayToBuffer(chunk);11429 -1 }11430 -111431 -1 if (addToFront) {11432 -1 if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);11433 -1 } else if (state.ended) {11434 -1 errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());11435 -1 } else if (state.destroyed) {11436 -1 return false;11437 -1 } else {11438 -1 state.reading = false;11439 -111440 -1 if (state.decoder && !encoding) {11441 -1 chunk = state.decoder.write(chunk);11442 -1 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);11443 -1 } else {11444 -1 addChunk(stream, state, chunk, false);11445 -1 }11446 -1 }11447 -1 } else if (!addToFront) {11448 -1 state.reading = false;11449 -1 maybeReadMore(stream, state);11450 -1 }11451 -1 } // We can push more data if we are below the highWaterMark.11452 -1 // Also, if we have no data yet, we can stand some more bytes.11453 -1 // This is to work around cases where hwm=0, such as the repl.11454 -111455 -111456 -1 return !state.ended && (state.length < state.highWaterMark || state.length === 0);11457 -1 }11458 -111459 -1 function addChunk(stream, state, chunk, addToFront) {11460 -1 if (state.flowing && state.length === 0 && !state.sync) {11461 -1 state.awaitDrain = 0;11462 -1 stream.emit('data', chunk);11463 -1 } else {11464 -1 // update the buffer info.11465 -1 state.length += state.objectMode ? 1 : chunk.length;11466 -1 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);11467 -1 if (state.needReadable) emitReadable(stream);11468 -1 }11469 -111470 -1 maybeReadMore(stream, state);11471 -1 }11472 -111473 -1 function chunkInvalid(state, chunk) {11474 -1 var er;11475 -111476 -1 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {11477 -1 er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);11478 -1 }11479 -111480 -1 return er;11481 -1 }11482 -111483 -1 Readable.prototype.isPaused = function () {11484 -1 return this._readableState.flowing === false;11485 -1 }; // backwards compatibility.11486 -111487 -111488 -1 Readable.prototype.setEncoding = function (enc) {11489 -1 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;11490 -1 var decoder = new StringDecoder(enc);11491 -1 this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf811492 -111493 -1 this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:11494 -111495 -1 var p = this._readableState.buffer.head;11496 -1 var content = '';11497 -111498 -1 while (p !== null) {11499 -1 content += decoder.write(p.data);11500 -1 p = p.next;11501 -1 }11502 -111503 -1 this._readableState.buffer.clear();11504 -111505 -1 if (content !== '') this._readableState.buffer.push(content);11506 -1 this._readableState.length = content.length;11507 -1 return this;11508 -1 }; // Don't raise the hwm > 1GB11509 -111510 -111511 -1 var MAX_HWM = 0x40000000;11512 -111513 -1 function computeNewHighWaterMark(n) {11514 -1 if (n >= MAX_HWM) {11515 -1 // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.11516 -1 n = MAX_HWM;11517 -1 } else {11518 -1 // Get the next highest power of 2 to prevent increasing hwm excessively in11519 -1 // tiny amounts11520 -1 n--;11521 -1 n |= n >>> 1;11522 -1 n |= n >>> 2;11523 -1 n |= n >>> 4;11524 -1 n |= n >>> 8;11525 -1 n |= n >>> 16;11526 -1 n++;11527 -1 }11528 -111529 -1 return n;11530 -1 } // This function is designed to be inlinable, so please take care when making11531 -1 // changes to the function body.11532 -111533 -111534 -1 function howMuchToRead(n, state) {11535 -1 if (n <= 0 || state.length === 0 && state.ended) return 0;11536 -1 if (state.objectMode) return 1;11537 -111538 -1 if (n !== n) {11539 -1 // Only flow one buffer at a time11540 -1 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;11541 -1 } // If we're asking for more than the current hwm, then raise the hwm.11542 -111543 -111544 -1 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);11545 -1 if (n <= state.length) return n; // Don't have enough11546 -111547 -1 if (!state.ended) {11548 -1 state.needReadable = true;11549 -1 return 0;11550 -1 }11551 -111552 -1 return state.length;11553 -1 } // you can override either this method, or the async _read(n) below.11554 -111555 -111556 -1 Readable.prototype.read = function (n) {11557 -1 debug('read', n);11558 -1 n = parseInt(n, 10);11559 -1 var state = this._readableState;11560 -1 var nOrig = n;11561 -1 if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we11562 -1 // already have a bunch of data in the buffer, then just trigger11563 -1 // the 'readable' event and move on.11564 -111565 -1 if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {11566 -1 debug('read: emitReadable', state.length, state.ended);11567 -1 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);11568 -1 return null;11569 -1 }11570 -111571 -1 n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.11572 -111573 -1 if (n === 0 && state.ended) {11574 -1 if (state.length === 0) endReadable(this);11575 -1 return null;11576 -1 } // All the actual chunk generation logic needs to be11577 -1 // *below* the call to _read. The reason is that in certain11578 -1 // synthetic stream cases, such as passthrough streams, _read11579 -1 // may be a completely synchronous operation which may change11580 -1 // the state of the read buffer, providing enough data when11581 -1 // before there was *not* enough.11582 -1 //11583 -1 // So, the steps are:11584 -1 // 1. Figure out what the state of things will be after we do11585 -1 // a read from the buffer.11586 -1 //11587 -1 // 2. If that resulting state will trigger a _read, then call _read.11588 -1 // Note that this may be asynchronous, or synchronous. Yes, it is11589 -1 // deeply ugly to write APIs this way, but that still doesn't mean11590 -1 // that the Readable class should behave improperly, as streams are11591 -1 // designed to be sync/async agnostic.11592 -1 // Take note if the _read call is sync or async (ie, if the read call11593 -1 // has returned yet), so that we know whether or not it's safe to emit11594 -1 // 'readable' etc.11595 -1 //11596 -1 // 3. Actually pull the requested chunks out of the buffer and return.11597 -1 // if we need a readable event, then we need to do some reading.11598 -111599 -111600 -1 var doRead = state.needReadable;11601 -1 debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some11602 -111603 -1 if (state.length === 0 || state.length - n < state.highWaterMark) {11604 -1 doRead = true;11605 -1 debug('length less than watermark', doRead);11606 -1 } // however, if we've ended, then there's no point, and if we're already11607 -1 // reading, then it's unnecessary.11608 -111609 -111610 -1 if (state.ended || state.reading) {11611 -1 doRead = false;11612 -1 debug('reading or ended', doRead);11613 -1 } else if (doRead) {11614 -1 debug('do read');11615 -1 state.reading = true;11616 -1 state.sync = true; // if the length is currently zero, then we *need* a readable event.11617 -111618 -1 if (state.length === 0) state.needReadable = true; // call internal read method11619 -111620 -1 this._read(state.highWaterMark);11621 -111622 -1 state.sync = false; // If _read pushed data synchronously, then `reading` will be false,11623 -1 // and we need to re-evaluate how much data we can return to the user.11624 -111625 -1 if (!state.reading) n = howMuchToRead(nOrig, state);11626 -1 }11627 -111628 -1 var ret;11629 -1 if (n > 0) ret = fromList(n, state);else ret = null;11630 -111631 -1 if (ret === null) {11632 -1 state.needReadable = state.length <= state.highWaterMark;11633 -1 n = 0;11634 -1 } else {11635 -1 state.length -= n;11636 -1 state.awaitDrain = 0;11637 -1 }11638 -111639 -1 if (state.length === 0) {11640 -1 // If we have nothing in the buffer, then we want to know11641 -1 // as soon as we *do* get something into the buffer.11642 -1 if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.11643 -111644 -1 if (nOrig !== n && state.ended) endReadable(this);11645 -1 }11646 -111647 -1 if (ret !== null) this.emit('data', ret);11648 -1 return ret;11649 -1 };11650 -111651 -1 function onEofChunk(stream, state) {11652 -1 debug('onEofChunk');11653 -1 if (state.ended) return;11654 -111655 -1 if (state.decoder) {11656 -1 var chunk = state.decoder.end();11657 -111658 -1 if (chunk && chunk.length) {11659 -1 state.buffer.push(chunk);11660 -1 state.length += state.objectMode ? 1 : chunk.length;11661 -1 }11662 -1 }11663 -111664 -1 state.ended = true;11665 -111666 -1 if (state.sync) {11667 -1 // if we are sync, wait until next tick to emit the data.11668 -1 // Otherwise we risk emitting data in the flow()11669 -1 // the readable code triggers during a read() call11670 -1 emitReadable(stream);11671 -1 } else {11672 -1 // emit 'readable' now to make sure it gets picked up.11673 -1 state.needReadable = false;11674 -111675 -1 if (!state.emittedReadable) {11676 -1 state.emittedReadable = true;11677 -1 emitReadable_(stream);11678 -1 }11679 -1 }11680 -1 } // Don't emit readable right away in sync mode, because this can trigger11681 -1 // another read() call => stack overflow. This way, it might trigger11682 -1 // a nextTick recursion warning, but that's not so bad.11683 -111684 -111685 -1 function emitReadable(stream) {11686 -1 var state = stream._readableState;11687 -1 debug('emitReadable', state.needReadable, state.emittedReadable);11688 -1 state.needReadable = false;11689 -111690 -1 if (!state.emittedReadable) {11691 -1 debug('emitReadable', state.flowing);11692 -1 state.emittedReadable = true;11693 -1 process.nextTick(emitReadable_, stream);11694 -1 }11695 -1 }11696 -111697 -1 function emitReadable_(stream) {11698 -1 var state = stream._readableState;11699 -1 debug('emitReadable_', state.destroyed, state.length, state.ended);11700 -111701 -1 if (!state.destroyed && (state.length || state.ended)) {11702 -1 stream.emit('readable');11703 -1 state.emittedReadable = false;11704 -1 } // The stream needs another readable event if11705 -1 // 1. It is not flowing, as the flow mechanism will take11706 -1 // care of it.11707 -1 // 2. It is not ended.11708 -1 // 3. It is below the highWaterMark, so we can schedule11709 -1 // another readable later.11710 -111711 -111712 -1 state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;11713 -1 flow(stream);11714 -1 } // at this point, the user has presumably seen the 'readable' event,11715 -1 // and called read() to consume some data. that may have triggered11716 -1 // in turn another _read(n) call, in which case reading = true if11717 -1 // it's in progress.11718 -1 // However, if we're not ended, or reading, and the length < hwm,11719 -1 // then go ahead and try to read some more preemptively.11720 -111721 -111722 -1 function maybeReadMore(stream, state) {11723 -1 if (!state.readingMore) {11724 -1 state.readingMore = true;11725 -1 process.nextTick(maybeReadMore_, stream, state);11726 -1 }11727 -1 }11728 -111729 -1 function maybeReadMore_(stream, state) {11730 -1 // Attempt to read more data if we should.11731 -1 //11732 -1 // The conditions for reading more data are (one of):11733 -1 // - Not enough data buffered (state.length < state.highWaterMark). The loop11734 -1 // is responsible for filling the buffer with enough data if such data11735 -1 // is available. If highWaterMark is 0 and we are not in the flowing mode11736 -1 // we should _not_ attempt to buffer any extra data. We'll get more data11737 -1 // when the stream consumer calls read() instead.11738 -1 // - No data in the buffer, and the stream is in flowing mode. In this mode11739 -1 // the loop below is responsible for ensuring read() is called. Failing to11740 -1 // call read here would abort the flow and there's no other mechanism for11741 -1 // continuing the flow if the stream consumer has just subscribed to the11742 -1 // 'data' event.11743 -1 //11744 -1 // In addition to the above conditions to keep reading data, the following11745 -1 // conditions prevent the data from being read:11746 -1 // - The stream has ended (state.ended).11747 -1 // - There is already a pending 'read' operation (state.reading). This is a11748 -1 // case where the the stream has called the implementation defined _read()11749 -1 // method, but they are processing the call asynchronously and have _not_11750 -1 // called push() with new data. In this case we skip performing more11751 -1 // read()s. The execution ends in this method again after the _read() ends11752 -1 // up calling push() with more data.11753 -1 while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {11754 -1 var len = state.length;11755 -1 debug('maybeReadMore read 0');11756 -1 stream.read(0);11757 -1 if (len === state.length) // didn't get any data, stop spinning.11758 -1 break;11759 -1 }11760 -111761 -1 state.readingMore = false;11762 -1 } // abstract method. to be overridden in specific implementation classes.11763 -1 // call cb(er, data) where data is <= n in length.11764 -1 // for virtual (non-string, non-buffer) streams, "length" is somewhat11765 -1 // arbitrary, and perhaps not very meaningful.11766 -111767 -111768 -1 Readable.prototype._read = function (n) {11769 -1 errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));11770 -1 };11771 -111772 -1 Readable.prototype.pipe = function (dest, pipeOpts) {11773 -1 var src = this;11774 -1 var state = this._readableState;11775 -111776 -1 switch (state.pipesCount) {11777 -1 case 0:11778 -1 state.pipes = dest;11779 -1 break;11780 -111781 -1 case 1:11782 -1 state.pipes = [state.pipes, dest];11783 -1 break;11784 -111785 -1 default:11786 -1 state.pipes.push(dest);11787 -1 break;11788 -1 }11789 -111790 -1 state.pipesCount += 1;11791 -1 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);11792 -1 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;11793 -1 var endFn = doEnd ? onend : unpipe;11794 -1 if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);11795 -1 dest.on('unpipe', onunpipe);11796 -111797 -1 function onunpipe(readable, unpipeInfo) {11798 -1 debug('onunpipe');11799 -111800 -1 if (readable === src) {11801 -1 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {11802 -1 unpipeInfo.hasUnpiped = true;11803 -1 cleanup();11804 -1 }11805 -1 }11806 -1 }11807 -111808 -1 function onend() {11809 -1 debug('onend');11810 -1 dest.end();11811 -1 } // when the dest drains, it reduces the awaitDrain counter11812 -1 // on the source. This would be more elegant with a .once()11813 -1 // handler in flow(), but adding and removing repeatedly is11814 -1 // too slow.11815 -111816 -111817 -1 var ondrain = pipeOnDrain(src);11818 -1 dest.on('drain', ondrain);11819 -1 var cleanedUp = false;11820 -111821 -1 function cleanup() {11822 -1 debug('cleanup'); // cleanup event handlers once the pipe is broken11823 -111824 -1 dest.removeListener('close', onclose);11825 -1 dest.removeListener('finish', onfinish);11826 -1 dest.removeListener('drain', ondrain);11827 -1 dest.removeListener('error', onerror);11828 -1 dest.removeListener('unpipe', onunpipe);11829 -1 src.removeListener('end', onend);11830 -1 src.removeListener('end', unpipe);11831 -1 src.removeListener('data', ondata);11832 -1 cleanedUp = true; // if the reader is waiting for a drain event from this11833 -1 // specific writer, then it would cause it to never start11834 -1 // flowing again.11835 -1 // So, if this is awaiting a drain, then we just call it now.11836 -1 // If we don't know, then assume that we are waiting for one.11837 -111838 -1 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();11839 -1 }11840 -111841 -1 src.on('data', ondata);11842 -111843 -1 function ondata(chunk) {11844 -1 debug('ondata');11845 -1 var ret = dest.write(chunk);11846 -1 debug('dest.write', ret);11847 -111848 -1 if (ret === false) {11849 -1 // If the user unpiped during `dest.write()`, it is possible11850 -1 // to get stuck in a permanently paused state if that write11851 -1 // also returned false.11852 -1 // => Check whether `dest` is still a piping destination.11853 -1 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {11854 -1 debug('false write response, pause', state.awaitDrain);11855 -1 state.awaitDrain++;11856 -1 }11857 -111858 -1 src.pause();11859 -1 }11860 -1 } // if the dest has an error, then stop piping into it.11861 -1 // however, don't suppress the throwing behavior for this.11862 -111863 -111864 -1 function onerror(er) {11865 -1 debug('onerror', er);11866 -1 unpipe();11867 -1 dest.removeListener('error', onerror);11868 -1 if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);11869 -1 } // Make sure our error handler is attached before userland ones.11870 -111871 -111872 -1 prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.11873 -111874 -1 function onclose() {11875 -1 dest.removeListener('finish', onfinish);11876 -1 unpipe();11877 -1 }11878 -111879 -1 dest.once('close', onclose);11880 -111881 -1 function onfinish() {11882 -1 debug('onfinish');11883 -1 dest.removeListener('close', onclose);11884 -1 unpipe();11885 -1 }11886 -111887 -1 dest.once('finish', onfinish);11888 -111889 -1 function unpipe() {11890 -1 debug('unpipe');11891 -1 src.unpipe(dest);11892 -1 } // tell the dest that it's being piped to11893 -111894 -111895 -1 dest.emit('pipe', src); // start the flow if it hasn't been started already.11896 -111897 -1 if (!state.flowing) {11898 -1 debug('pipe resume');11899 -1 src.resume();11900 -1 }11901 -111902 -1 return dest;11903 -1 };11904 -111905 -1 function pipeOnDrain(src) {11906 -1 return function pipeOnDrainFunctionResult() {11907 -1 var state = src._readableState;11908 -1 debug('pipeOnDrain', state.awaitDrain);11909 -1 if (state.awaitDrain) state.awaitDrain--;11910 -111911 -1 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {11912 -1 state.flowing = true;11913 -1 flow(src);11914 -1 }11915 -1 };11916 -1 }11917 -111918 -1 Readable.prototype.unpipe = function (dest) {11919 -1 var state = this._readableState;11920 -1 var unpipeInfo = {11921 -1 hasUnpiped: false11922 -1 }; // if we're not piping anywhere, then do nothing.11923 -111924 -1 if (state.pipesCount === 0) return this; // just one destination. most common case.11925 -111926 -1 if (state.pipesCount === 1) {11927 -1 // passed in one, but it's not the right one.11928 -1 if (dest && dest !== state.pipes) return this;11929 -1 if (!dest) dest = state.pipes; // got a match.11930 -111931 -1 state.pipes = null;11932 -1 state.pipesCount = 0;11933 -1 state.flowing = false;11934 -1 if (dest) dest.emit('unpipe', this, unpipeInfo);11935 -1 return this;11936 -1 } // slow case. multiple pipe destinations.11937 -111938 -111939 -1 if (!dest) {11940 -1 // remove all.11941 -1 var dests = state.pipes;11942 -1 var len = state.pipesCount;11943 -1 state.pipes = null;11944 -1 state.pipesCount = 0;11945 -1 state.flowing = false;11946 -111947 -1 for (var i = 0; i < len; i++) {11948 -1 dests[i].emit('unpipe', this, {11949 -1 hasUnpiped: false11950 -1 });11951 -1 }11952 -111953 -1 return this;11954 -1 } // try to find the right one.11955 -111956 -111957 -1 var index = indexOf(state.pipes, dest);11958 -1 if (index === -1) return this;11959 -1 state.pipes.splice(index, 1);11960 -1 state.pipesCount -= 1;11961 -1 if (state.pipesCount === 1) state.pipes = state.pipes[0];11962 -1 dest.emit('unpipe', this, unpipeInfo);11963 -1 return this;11964 -1 }; // set up data events if they are asked for11965 -1 // Ensure readable listeners eventually get something11966 -111967 -111968 -1 Readable.prototype.on = function (ev, fn) {11969 -1 var res = Stream.prototype.on.call(this, ev, fn);11970 -1 var state = this._readableState;11971 -111972 -1 if (ev === 'data') {11973 -1 // update readableListening so that resume() may be a no-op11974 -1 // a few lines down. This is needed to support once('readable').11975 -1 state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused11976 -111977 -1 if (state.flowing !== false) this.resume();11978 -1 } else if (ev === 'readable') {11979 -1 if (!state.endEmitted && !state.readableListening) {11980 -1 state.readableListening = state.needReadable = true;11981 -1 state.flowing = false;11982 -1 state.emittedReadable = false;11983 -1 debug('on readable', state.length, state.reading);11984 -111985 -1 if (state.length) {11986 -1 emitReadable(this);11987 -1 } else if (!state.reading) {11988 -1 process.nextTick(nReadingNextTick, this);11989 -1 }11990 -1 }11991 -1 }11992 -111993 -1 return res;11994 -1 };11995 -111996 -1 Readable.prototype.addListener = Readable.prototype.on;11997 -111998 -1 Readable.prototype.removeListener = function (ev, fn) {11999 -1 var res = Stream.prototype.removeListener.call(this, ev, fn);12000 -112001 -1 if (ev === 'readable') {12002 -1 // We need to check if there is someone still listening to12003 -1 // readable and reset the state. However this needs to happen12004 -1 // after readable has been emitted but before I/O (nextTick) to12005 -1 // support once('readable', fn) cycles. This means that calling12006 -1 // resume within the same tick will have no12007 -1 // effect.12008 -1 process.nextTick(updateReadableListening, this);12009 -1 }12010 -112011 -1 return res;12012 -1 };12013 -112014 -1 Readable.prototype.removeAllListeners = function (ev) {12015 -1 var res = Stream.prototype.removeAllListeners.apply(this, arguments);12016 -112017 -1 if (ev === 'readable' || ev === undefined) {12018 -1 // We need to check if there is someone still listening to12019 -1 // readable and reset the state. However this needs to happen12020 -1 // after readable has been emitted but before I/O (nextTick) to12021 -1 // support once('readable', fn) cycles. This means that calling12022 -1 // resume within the same tick will have no12023 -1 // effect.12024 -1 process.nextTick(updateReadableListening, this);12025 -1 }12026 -112027 -1 return res;12028 -1 };12029 -112030 -1 function updateReadableListening(self) {12031 -1 var state = self._readableState;12032 -1 state.readableListening = self.listenerCount('readable') > 0;12033 -112034 -1 if (state.resumeScheduled && !state.paused) {12035 -1 // flowing needs to be set to true now, otherwise12036 -1 // the upcoming resume will not flow.12037 -1 state.flowing = true; // crude way to check if we should resume12038 -1 } else if (self.listenerCount('data') > 0) {12039 -1 self.resume();12040 -1 }12041 -1 }12042 -112043 -1 function nReadingNextTick(self) {12044 -1 debug('readable nexttick read 0');12045 -1 self.read(0);12046 -1 } // pause() and resume() are remnants of the legacy readable stream API12047 -1 // If the user uses them, then switch into old mode.12048 -112049 -112050 -1 Readable.prototype.resume = function () {12051 -1 var state = this._readableState;12052 -112053 -1 if (!state.flowing) {12054 -1 debug('resume'); // we flow only if there is no one listening12055 -1 // for readable, but we still have to call12056 -1 // resume()12057 -112058 -1 state.flowing = !state.readableListening;12059 -1 resume(this, state);12060 -1 }12061 -112062 -1 state.paused = false;12063 -1 return this;12064 -1 };12065 -112066 -1 function resume(stream, state) {12067 -1 if (!state.resumeScheduled) {12068 -1 state.resumeScheduled = true;12069 -1 process.nextTick(resume_, stream, state);12070 -1 }12071 -1 }12072 -112073 -1 function resume_(stream, state) {12074 -1 debug('resume', state.reading);12075 -112076 -1 if (!state.reading) {12077 -1 stream.read(0);12078 -1 }12079 -112080 -1 state.resumeScheduled = false;12081 -1 stream.emit('resume');12082 -1 flow(stream);12083 -1 if (state.flowing && !state.reading) stream.read(0);12084 -1 }12085 -112086 -1 Readable.prototype.pause = function () {12087 -1 debug('call pause flowing=%j', this._readableState.flowing);12088 -112089 -1 if (this._readableState.flowing !== false) {12090 -1 debug('pause');12091 -1 this._readableState.flowing = false;12092 -1 this.emit('pause');12093 -1 }12094 -112095 -1 this._readableState.paused = true;12096 -1 return this;12097 -1 };12098 -112099 -1 function flow(stream) {12100 -1 var state = stream._readableState;12101 -1 debug('flow', state.flowing);12102 -112103 -1 while (state.flowing && stream.read() !== null) {12104 -1 ;12105 -1 }12106 -1 } // wrap an old-style stream as the async data source.12107 -1 // This is *not* part of the readable stream interface.12108 -1 // It is an ugly unfortunate mess of history.12109 -112110 -112111 -1 Readable.prototype.wrap = function (stream) {12112 -1 var _this = this;12113 -112114 -1 var state = this._readableState;12115 -1 var paused = false;12116 -1 stream.on('end', function () {12117 -1 debug('wrapped end');12118 -112119 -1 if (state.decoder && !state.ended) {12120 -1 var chunk = state.decoder.end();12121 -1 if (chunk && chunk.length) _this.push(chunk);12122 -1 }12123 -112124 -1 _this.push(null);12125 -1 });12126 -1 stream.on('data', function (chunk) {12127 -1 debug('wrapped data');12128 -1 if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode12129 -112130 -1 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;12131 -112132 -1 var ret = _this.push(chunk);12133 -112134 -1 if (!ret) {12135 -1 paused = true;12136 -1 stream.pause();12137 -1 }12138 -1 }); // proxy all the other methods.12139 -1 // important when wrapping filters and duplexes.12140 -112141 -1 for (var i in stream) {12142 -1 if (this[i] === undefined && typeof stream[i] === 'function') {12143 -1 this[i] = function methodWrap(method) {12144 -1 return function methodWrapReturnFunction() {12145 -1 return stream[method].apply(stream, arguments);12146 -1 };12147 -1 }(i);12148 -1 }12149 -1 } // proxy certain important events.12150 -112151 -112152 -1 for (var n = 0; n < kProxyEvents.length; n++) {12153 -1 stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));12154 -1 } // when we try to consume some more bytes, simply unpause the12155 -1 // underlying stream.12156 -112157 -112158 -1 this._read = function (n) {12159 -1 debug('wrapped _read', n);12160 -112161 -1 if (paused) {12162 -1 paused = false;12163 -1 stream.resume();12164 -1 }12165 -1 };12166 -112167 -1 return this;12168 -1 };12169 -112170 -1 if (typeof Symbol === 'function') {12171 -1 Readable.prototype[Symbol.asyncIterator] = function () {12172 -1 if (createReadableStreamAsyncIterator === undefined) {12173 -1 createReadableStreamAsyncIterator = require('./internal/streams/async_iterator');12174 -1 }12175 -112176 -1 return createReadableStreamAsyncIterator(this);12177 -1 };12178 -1 }12179 -112180 -1 Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {12181 -1 // making it explicit this property is not enumerable12182 -1 // because otherwise some prototype manipulation in12183 -1 // userland will fail12184 -1 enumerable: false,12185 -1 get: function get() {12186 -1 return this._readableState.highWaterMark;12187 -1 }12188 -1 });12189 -1 Object.defineProperty(Readable.prototype, 'readableBuffer', {12190 -1 // making it explicit this property is not enumerable12191 -1 // because otherwise some prototype manipulation in12192 -1 // userland will fail12193 -1 enumerable: false,12194 -1 get: function get() {12195 -1 return this._readableState && this._readableState.buffer;12196 -1 }12197 -1 });12198 -1 Object.defineProperty(Readable.prototype, 'readableFlowing', {12199 -1 // making it explicit this property is not enumerable12200 -1 // because otherwise some prototype manipulation in12201 -1 // userland will fail12202 -1 enumerable: false,12203 -1 get: function get() {12204 -1 return this._readableState.flowing;12205 -1 },12206 -1 set: function set(state) {12207 -1 if (this._readableState) {12208 -1 this._readableState.flowing = state;12209 -1 }12210 -1 }12211 -1 }); // exposed for testing purposes only.12212 -112213 -1 Readable._fromList = fromList;12214 -1 Object.defineProperty(Readable.prototype, 'readableLength', {12215 -1 // making it explicit this property is not enumerable12216 -1 // because otherwise some prototype manipulation in12217 -1 // userland will fail12218 -1 enumerable: false,12219 -1 get: function get() {12220 -1 return this._readableState.length;12221 -1 }12222 -1 }); // Pluck off n bytes from an array of buffers.12223 -1 // Length is the combined lengths of all the buffers in the list.12224 -1 // This function is designed to be inlinable, so please take care when making12225 -1 // changes to the function body.12226 -112227 -1 function fromList(n, state) {12228 -1 // nothing buffered12229 -1 if (state.length === 0) return null;12230 -1 var ret;12231 -1 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {12232 -1 // read it all, truncate the list12233 -1 if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);12234 -1 state.buffer.clear();12235 -1 } else {12236 -1 // read part of list12237 -1 ret = state.buffer.consume(n, state.decoder);12238 -1 }12239 -1 return ret;12240 -1 }12241 -112242 -1 function endReadable(stream) {12243 -1 var state = stream._readableState;12244 -1 debug('endReadable', state.endEmitted);12245 -112246 -1 if (!state.endEmitted) {12247 -1 state.ended = true;12248 -1 process.nextTick(endReadableNT, state, stream);12249 -1 }12250 -1 }12251 -112252 -1 function endReadableNT(state, stream) {12253 -1 debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift.12254 -112255 -1 if (!state.endEmitted && state.length === 0) {12256 -1 state.endEmitted = true;12257 -1 stream.readable = false;12258 -1 stream.emit('end');12259 -112260 -1 if (state.autoDestroy) {12261 -1 // In case of duplex streams we need a way to detect12262 -1 // if the writable side is ready for autoDestroy as well12263 -1 var wState = stream._writableState;12264 -112265 -1 if (!wState || wState.autoDestroy && wState.finished) {12266 -1 stream.destroy();12267 -1 }12268 -1 }12269 -1 }12270 -1 }12271 -112272 -1 if (typeof Symbol === 'function') {12273 -1 Readable.from = function (iterable, opts) {12274 -1 if (from === undefined) {12275 -1 from = require('./internal/streams/from');12276 -1 }12277 -112278 -1 return from(Readable, iterable, opts);12279 -1 };12280 -1 }12281 -112282 -1 function indexOf(xs, x) {12283 -1 for (var i = 0, l = xs.length; i < l; i++) {12284 -1 if (xs[i] === x) return i;12285 -1 }12286 -112287 -1 return -1;12288 -1 }12289 -1 }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})12290 -1 },{"../errors":47,"./_stream_duplex":48,"./internal/streams/async_iterator":53,"./internal/streams/buffer_list":54,"./internal/streams/destroy":55,"./internal/streams/from":57,"./internal/streams/state":59,"./internal/streams/stream":60,"_process":149,"buffer":63,"events":100,"inherits":132,"string_decoder/":185,"util":19}],51:[function(require,module,exports){12291 -1 // Copyright Joyent, Inc. and other Node contributors.12292 -1 //12293 -1 // Permission is hereby granted, free of charge, to any person obtaining a12294 -1 // copy of this software and associated documentation files (the12295 -1 // "Software"), to deal in the Software without restriction, including12296 -1 // without limitation the rights to use, copy, modify, merge, publish,12297 -1 // distribute, sublicense, and/or sell copies of the Software, and to permit12298 -1 // persons to whom the Software is furnished to do so, subject to the12299 -1 // following conditions:12300 -1 //12301 -1 // The above copyright notice and this permission notice shall be included12302 -1 // in all copies or substantial portions of the Software.12303 -1 //12304 -1 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS12305 -1 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF12306 -1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN12307 -1 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,12308 -1 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR12309 -1 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE12310 -1 // USE OR OTHER DEALINGS IN THE SOFTWARE.12311 -1 // a transform stream is a readable/writable stream where you do12312 -1 // something with the data. Sometimes it's called a "filter",12313 -1 // but that's not a great name for it, since that implies a thing where12314 -1 // some bits pass through, and others are simply ignored. (That would12315 -1 // be a valid example of a transform, of course.)12316 -1 //12317 -1 // While the output is causally related to the input, it's not a12318 -1 // necessarily symmetric or synchronous transformation. For example,12319 -1 // a zlib stream might take multiple plain-text writes(), and then12320 -1 // emit a single compressed chunk some time in the future.12321 -1 //12322 -1 // Here's how this works:12323 -1 //12324 -1 // The Transform stream has all the aspects of the readable and writable12325 -1 // stream classes. When you write(chunk), that calls _write(chunk,cb)12326 -1 // internally, and returns false if there's a lot of pending writes12327 -1 // buffered up. When you call read(), that calls _read(n) until12328 -1 // there's enough pending readable data buffered up.12329 -1 //12330 -1 // In a transform stream, the written data is placed in a buffer. When12331 -1 // _read(n) is called, it transforms the queued up data, calling the12332 -1 // buffered _write cb's as it consumes chunks. If consuming a single12333 -1 // written chunk would result in multiple output chunks, then the first12334 -1 // outputted bit calls the readcb, and subsequent chunks just go into12335 -1 // the read buffer, and will cause it to emit 'readable' if necessary.12336 -1 //12337 -1 // This way, back-pressure is actually determined by the reading side,12338 -1 // since _read has to be called to start processing a new chunk. However,12339 -1 // a pathological inflate type of transform can cause excessive buffering12340 -1 // here. For example, imagine a stream where every byte of input is12341 -1 // interpreted as an integer from 0-255, and then results in that many12342 -1 // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in12343 -1 // 1kb of data being output. In this case, you could write a very small12344 -1 // amount of input, and end up with a very large amount of output. In12345 -1 // such a pathological inflating mechanism, there'd be no way to tell12346 -1 // the system to stop doing the transform. A single 4MB write could12347 -1 // cause the system to run out of memory.12348 -1 //12349 -1 // However, even in such a pathological case, only a single written chunk12350 -1 // would be consumed, and then the rest would wait (un-transformed) until12351 -1 // the results of the previous transformed chunk were consumed.12352 -1 'use strict';12353 -112354 -1 module.exports = Transform;12355 -112356 -1 var _require$codes = require('../errors').codes,12357 -1 ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,12358 -1 ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,12359 -1 ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,12360 -1 ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;12361 -112362 -1 var Duplex = require('./_stream_duplex');12363 -112364 -1 require('inherits')(Transform, Duplex);12365 -112366 -1 function afterTransform(er, data) {12367 -1 var ts = this._transformState;12368 -1 ts.transforming = false;12369 -1 var cb = ts.writecb;12370 -112371 -1 if (cb === null) {12372 -1 return this.emit('error', new ERR_MULTIPLE_CALLBACK());12373 -1 }12374 -112375 -1 ts.writechunk = null;12376 -1 ts.writecb = null;12377 -1 if (data != null) // single equals check for both `null` and `undefined`12378 -1 this.push(data);12379 -1 cb(er);12380 -1 var rs = this._readableState;12381 -1 rs.reading = false;12382 -112383 -1 if (rs.needReadable || rs.length < rs.highWaterMark) {12384 -1 this._read(rs.highWaterMark);12385 -1 }12386 -1 }12387 -112388 -1 function Transform(options) {12389 -1 if (!(this instanceof Transform)) return new Transform(options);12390 -1 Duplex.call(this, options);12391 -1 this._transformState = {12392 -1 afterTransform: afterTransform.bind(this),12393 -1 needTransform: false,12394 -1 transforming: false,12395 -1 writecb: null,12396 -1 writechunk: null,12397 -1 writeencoding: null12398 -1 }; // start out asking for a readable event once data is transformed.12399 -112400 -1 this._readableState.needReadable = true; // we have implemented the _read method, and done the other things12401 -1 // that Readable wants before the first _read call, so unset the12402 -1 // sync guard flag.12403 -112404 -1 this._readableState.sync = false;12405 -112406 -1 if (options) {12407 -1 if (typeof options.transform === 'function') this._transform = options.transform;12408 -1 if (typeof options.flush === 'function') this._flush = options.flush;12409 -1 } // When the writable side finishes, then flush out anything remaining.12410 -112411 -112412 -1 this.on('prefinish', prefinish);12413 -1 }12414 -112415 -1 function prefinish() {12416 -1 var _this = this;12417 -112418 -1 if (typeof this._flush === 'function' && !this._readableState.destroyed) {12419 -1 this._flush(function (er, data) {12420 -1 done(_this, er, data);12421 -1 });12422 -1 } else {12423 -1 done(this, null, null);12424 -1 }12425 -1 }12426 -112427 -1 Transform.prototype.push = function (chunk, encoding) {12428 -1 this._transformState.needTransform = false;12429 -1 return Duplex.prototype.push.call(this, chunk, encoding);12430 -1 }; // This is the part where you do stuff!12431 -1 // override this function in implementation classes.12432 -1 // 'chunk' is an input chunk.12433 -1 //12434 -1 // Call `push(newChunk)` to pass along transformed output12435 -1 // to the readable side. You may call 'push' zero or more times.12436 -1 //12437 -1 // Call `cb(err)` when you are done with this chunk. If you pass12438 -1 // an error, then that'll put the hurt on the whole operation. If you12439 -1 // never call cb(), then you'll never get another chunk.12440 -112441 -112442 -1 Transform.prototype._transform = function (chunk, encoding, cb) {12443 -1 cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));12444 -1 };12445 -112446 -1 Transform.prototype._write = function (chunk, encoding, cb) {12447 -1 var ts = this._transformState;12448 -1 ts.writecb = cb;12449 -1 ts.writechunk = chunk;12450 -1 ts.writeencoding = encoding;12451 -112452 -1 if (!ts.transforming) {12453 -1 var rs = this._readableState;12454 -1 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);12455 -1 }12456 -1 }; // Doesn't matter what the args are here.12457 -1 // _transform does all the work.12458 -1 // That we got here means that the readable side wants more data.12459 -112460 -112461 -1 Transform.prototype._read = function (n) {12462 -1 var ts = this._transformState;12463 -112464 -1 if (ts.writechunk !== null && !ts.transforming) {12465 -1 ts.transforming = true;12466 -112467 -1 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);12468 -1 } else {12469 -1 // mark that we need a transform, so that any data that comes in12470 -1 // will get processed, now that we've asked for it.12471 -1 ts.needTransform = true;12472 -1 }12473 -1 };12474 -112475 -1 Transform.prototype._destroy = function (err, cb) {12476 -1 Duplex.prototype._destroy.call(this, err, function (err2) {12477 -1 cb(err2);12478 -1 });12479 -1 };12480 -112481 -1 function done(stream, er, data) {12482 -1 if (er) return stream.emit('error', er);12483 -1 if (data != null) // single equals check for both `null` and `undefined`12484 -1 stream.push(data); // TODO(BridgeAR): Write a test for these two error cases12485 -1 // if there's nothing in the write buffer, then that means12486 -1 // that nothing more will ever be provided12487 -112488 -1 if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();12489 -1 if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();12490 -1 return stream.push(null);12491 -1 }12492 -1 },{"../errors":47,"./_stream_duplex":48,"inherits":132}],52:[function(require,module,exports){12493 -1 (function (process,global){(function (){12494 -1 // Copyright Joyent, Inc. and other Node contributors.12495 -1 //12496 -1 // Permission is hereby granted, free of charge, to any person obtaining a12497 -1 // copy of this software and associated documentation files (the12498 -1 // "Software"), to deal in the Software without restriction, including12499 -1 // without limitation the rights to use, copy, modify, merge, publish,12500 -1 // distribute, sublicense, and/or sell copies of the Software, and to permit12501 -1 // persons to whom the Software is furnished to do so, subject to the12502 -1 // following conditions:12503 -1 //12504 -1 // The above copyright notice and this permission notice shall be included12505 -1 // in all copies or substantial portions of the Software.12506 -1 //12507 -1 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS12508 -1 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF12509 -1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN12510 -1 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,12511 -1 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR12512 -1 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE12513 -1 // USE OR OTHER DEALINGS IN THE SOFTWARE.12514 -1 // A bit simpler than readable streams.12515 -1 // Implement an async ._write(chunk, encoding, cb), and it'll handle all12516 -1 // the drain event emission and buffering.12517 -1 'use strict';12518 -112519 -1 module.exports = Writable;12520 -1 /* <replacement> */12521 -112522 -1 function WriteReq(chunk, encoding, cb) {12523 -1 this.chunk = chunk;12524 -1 this.encoding = encoding;12525 -1 this.callback = cb;12526 -1 this.next = null;12527 -1 } // It seems a linked list but it is not12528 -1 // there will be only 2 of these for each stream12529 -112530 -112531 -1 function CorkedRequest(state) {12532 -1 var _this = this;12533 -112534 -1 this.next = null;12535 -1 this.entry = null;12536 -112537 -1 this.finish = function () {12538 -1 onCorkedFinish(_this, state);12539 -1 };12540 -1 }12541 -1 /* </replacement> */12542 -112543 -1 /*<replacement>*/12544 -112545 -112546 -1 var Duplex;12547 -1 /*</replacement>*/12548 -112549 -1 Writable.WritableState = WritableState;12550 -1 /*<replacement>*/12551 -112552 -1 var internalUtil = {12553 -1 deprecate: require('util-deprecate')12554 -1 };12555 -1 /*</replacement>*/12556 -112557 -1 /*<replacement>*/12558 -112559 -1 var Stream = require('./internal/streams/stream');12560 -1 /*</replacement>*/12561 -112562 -112563 -1 var Buffer = require('buffer').Buffer;12564 -112565 -1 var OurUint8Array = global.Uint8Array || function () {};12566 -112567 -1 function _uint8ArrayToBuffer(chunk) {12568 -1 return Buffer.from(chunk);12569 -1 }12570 -112571 -1 function _isUint8Array(obj) {12572 -1 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;12573 -1 }12574 -112575 -1 var destroyImpl = require('./internal/streams/destroy');12576 -112577 -1 var _require = require('./internal/streams/state'),12578 -1 getHighWaterMark = _require.getHighWaterMark;12579 -112580 -1 var _require$codes = require('../errors').codes,12581 -1 ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,12582 -1 ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,12583 -1 ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,12584 -1 ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,12585 -1 ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,12586 -1 ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,12587 -1 ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,12588 -1 ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;12589 -112590 -1 var errorOrDestroy = destroyImpl.errorOrDestroy;12591 -112592 -1 require('inherits')(Writable, Stream);12593 -112594 -1 function nop() {}12595 -112596 -1 function WritableState(options, stream, isDuplex) {12597 -1 Duplex = Duplex || require('./_stream_duplex');12598 -1 options = options || {}; // Duplex streams are both readable and writable, but share12599 -1 // the same options object.12600 -1 // However, some cases require setting options to different12601 -1 // values for the readable and the writable sides of the duplex stream,12602 -1 // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.12603 -112604 -1 if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream12605 -1 // contains buffers or objects.12606 -112607 -1 this.objectMode = !!options.objectMode;12608 -1 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false12609 -1 // Note: 0 is a valid value, means that we always return false if12610 -1 // the entire buffer is not flushed immediately on write()12611 -112612 -1 this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called12613 -112614 -1 this.finalCalled = false; // drain event flag.12615 -112616 -1 this.needDrain = false; // at the start of calling end()12617 -112618 -1 this.ending = false; // when end() has been called, and returned12619 -112620 -1 this.ended = false; // when 'finish' is emitted12621 -112622 -1 this.finished = false; // has it been destroyed12623 -112624 -1 this.destroyed = false; // should we decode strings into buffers before passing to _write?12625 -1 // this is here so that some node-core streams can optimize string12626 -1 // handling at a lower level.12627 -112628 -1 var noDecode = options.decodeStrings === false;12629 -1 this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string12630 -1 // encoding is 'binary' so we have to make this configurable.12631 -1 // Everything else in the universe uses 'utf8', though.12632 -112633 -1 this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement12634 -1 // of how much we're waiting to get pushed to some underlying12635 -1 // socket or file.12636 -112637 -1 this.length = 0; // a flag to see when we're in the middle of a write.12638 -112639 -1 this.writing = false; // when true all writes will be buffered until .uncork() call12640 -112641 -1 this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,12642 -1 // or on a later tick. We set this to true at first, because any12643 -1 // actions that shouldn't happen until "later" should generally also12644 -1 // not happen before the first write call.12645 -112646 -1 this.sync = true; // a flag to know if we're processing previously buffered items, which12647 -1 // may call the _write() callback in the same tick, so that we don't12648 -1 // end up in an overlapped onwrite situation.12649 -112650 -1 this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)12651 -112652 -1 this.onwrite = function (er) {12653 -1 onwrite(stream, er);12654 -1 }; // the callback that the user supplies to write(chunk,encoding,cb)12655 -112656 -112657 -1 this.writecb = null; // the amount that is being written when _write is called.12658 -112659 -1 this.writelen = 0;12660 -1 this.bufferedRequest = null;12661 -1 this.lastBufferedRequest = null; // number of pending user-supplied write callbacks12662 -1 // this must be 0 before 'finish' can be emitted12663 -112664 -1 this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs12665 -1 // This is relevant for synchronous Transform streams12666 -112667 -1 this.prefinished = false; // True if the error was already emitted and should not be thrown again12668 -112669 -1 this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.12670 -112671 -1 this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')12672 -112673 -1 this.autoDestroy = !!options.autoDestroy; // count buffered requests12674 -112675 -1 this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always12676 -1 // one allocated and free to use, and we maintain at most two12677 -112678 -1 this.corkedRequestsFree = new CorkedRequest(this);12679 -1 }12680 -112681 -1 WritableState.prototype.getBuffer = function getBuffer() {12682 -1 var current = this.bufferedRequest;12683 -1 var out = [];12684 -112685 -1 while (current) {12686 -1 out.push(current);12687 -1 current = current.next;12688 -1 }12689 -112690 -1 return out;12691 -1 };12692 -112693 -1 (function () {12694 -1 try {12695 -1 Object.defineProperty(WritableState.prototype, 'buffer', {12696 -1 get: internalUtil.deprecate(function writableStateBufferGetter() {12697 -1 return this.getBuffer();12698 -1 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')12699 -1 });12700 -1 } catch (_) {}12701 -1 })(); // Test _writableState for inheritance to account for Duplex streams,12702 -1 // whose prototype chain only points to Readable.12703 -112704 -112705 -1 var realHasInstance;12706 -112707 -1 if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {12708 -1 realHasInstance = Function.prototype[Symbol.hasInstance];12709 -1 Object.defineProperty(Writable, Symbol.hasInstance, {12710 -1 value: function value(object) {12711 -1 if (realHasInstance.call(this, object)) return true;12712 -1 if (this !== Writable) return false;12713 -1 return object && object._writableState instanceof WritableState;12714 -1 }12715 -1 });12716 -1 } else {12717 -1 realHasInstance = function realHasInstance(object) {12718 -1 return object instanceof this;12719 -1 };12720 -1 }12721 -112722 -1 function Writable(options) {12723 -1 Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too.12724 -1 // `realHasInstance` is necessary because using plain `instanceof`12725 -1 // would return false, as no `_writableState` property is attached.12726 -1 // Trying to use the custom `instanceof` for Writable here will also break the12727 -1 // Node.js LazyTransform implementation, which has a non-trivial getter for12728 -1 // `_writableState` that would lead to infinite recursion.12729 -1 // Checking for a Stream.Duplex instance is faster here instead of inside12730 -1 // the WritableState constructor, at least with V8 6.512731 -112732 -1 var isDuplex = this instanceof Duplex;12733 -1 if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);12734 -1 this._writableState = new WritableState(options, this, isDuplex); // legacy.12735 -112736 -1 this.writable = true;12737 -112738 -1 if (options) {12739 -1 if (typeof options.write === 'function') this._write = options.write;12740 -1 if (typeof options.writev === 'function') this._writev = options.writev;12741 -1 if (typeof options.destroy === 'function') this._destroy = options.destroy;12742 -1 if (typeof options.final === 'function') this._final = options.final;12743 -1 }12744 -112745 -1 Stream.call(this);12746 -1 } // Otherwise people can pipe Writable streams, which is just wrong.12747 -112748 -112749 -1 Writable.prototype.pipe = function () {12750 -1 errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());12751 -1 };12752 -112753 -1 function writeAfterEnd(stream, cb) {12754 -1 var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb12755 -112756 -1 errorOrDestroy(stream, er);12757 -1 process.nextTick(cb, er);12758 -1 } // Checks that a user-supplied chunk is valid, especially for the particular12759 -1 // mode the stream is in. Currently this means that `null` is never accepted12760 -1 // and undefined/non-string values are only allowed in object mode.12761 -112762 -112763 -1 function validChunk(stream, state, chunk, cb) {12764 -1 var er;12765 -112766 -1 if (chunk === null) {12767 -1 er = new ERR_STREAM_NULL_VALUES();12768 -1 } else if (typeof chunk !== 'string' && !state.objectMode) {12769 -1 er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);12770 -1 }12771 -112772 -1 if (er) {12773 -1 errorOrDestroy(stream, er);12774 -1 process.nextTick(cb, er);12775 -1 return false;12776 -1 }12777 -112778 -1 return true;12779 -1 }12780 -112781 -1 Writable.prototype.write = function (chunk, encoding, cb) {12782 -1 var state = this._writableState;12783 -1 var ret = false;12784 -112785 -1 var isBuf = !state.objectMode && _isUint8Array(chunk);12786 -112787 -1 if (isBuf && !Buffer.isBuffer(chunk)) {12788 -1 chunk = _uint8ArrayToBuffer(chunk);12789 -1 }12790 -112791 -1 if (typeof encoding === 'function') {12792 -1 cb = encoding;12793 -1 encoding = null;12794 -1 }12795 -112796 -1 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;12797 -1 if (typeof cb !== 'function') cb = nop;12798 -1 if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {12799 -1 state.pendingcb++;12800 -1 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);12801 -1 }12802 -1 return ret;12803 -1 };12804 -112805 -1 Writable.prototype.cork = function () {12806 -1 this._writableState.corked++;12807 -1 };12808 -112809 -1 Writable.prototype.uncork = function () {12810 -1 var state = this._writableState;12811 -112812 -1 if (state.corked) {12813 -1 state.corked--;12814 -1 if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);12815 -1 }12816 -1 };12817 -112818 -1 Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {12819 -1 // node::ParseEncoding() requires lower case.12820 -1 if (typeof encoding === 'string') encoding = encoding.toLowerCase();12821 -1 if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);12822 -1 this._writableState.defaultEncoding = encoding;12823 -1 return this;12824 -1 };12825 -112826 -1 Object.defineProperty(Writable.prototype, 'writableBuffer', {12827 -1 // making it explicit this property is not enumerable12828 -1 // because otherwise some prototype manipulation in12829 -1 // userland will fail12830 -1 enumerable: false,12831 -1 get: function get() {12832 -1 return this._writableState && this._writableState.getBuffer();12833 -1 }12834 -1 });12835 -112836 -1 function decodeChunk(state, chunk, encoding) {12837 -1 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {12838 -1 chunk = Buffer.from(chunk, encoding);12839 -1 }12840 -112841 -1 return chunk;12842 -1 }12843 -112844 -1 Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {12845 -1 // making it explicit this property is not enumerable12846 -1 // because otherwise some prototype manipulation in12847 -1 // userland will fail12848 -1 enumerable: false,12849 -1 get: function get() {12850 -1 return this._writableState.highWaterMark;12851 -1 }12852 -1 }); // if we're already writing something, then just put this12853 -1 // in the queue, and wait our turn. Otherwise, call _write12854 -1 // If we return false, then we need a drain event, so set that flag.12855 -112856 -1 function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {12857 -1 if (!isBuf) {12858 -1 var newChunk = decodeChunk(state, chunk, encoding);12859 -112860 -1 if (chunk !== newChunk) {12861 -1 isBuf = true;12862 -1 encoding = 'buffer';12863 -1 chunk = newChunk;12864 -1 }12865 -1 }12866 -112867 -1 var len = state.objectMode ? 1 : chunk.length;12868 -1 state.length += len;12869 -1 var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.12870 -112871 -1 if (!ret) state.needDrain = true;12872 -112873 -1 if (state.writing || state.corked) {12874 -1 var last = state.lastBufferedRequest;12875 -1 state.lastBufferedRequest = {12876 -1 chunk: chunk,12877 -1 encoding: encoding,12878 -1 isBuf: isBuf,12879 -1 callback: cb,12880 -1 next: null12881 -1 };12882 -112883 -1 if (last) {12884 -1 last.next = state.lastBufferedRequest;12885 -1 } else {12886 -1 state.bufferedRequest = state.lastBufferedRequest;12887 -1 }12888 -112889 -1 state.bufferedRequestCount += 1;12890 -1 } else {12891 -1 doWrite(stream, state, false, len, chunk, encoding, cb);12892 -1 }12893 -112894 -1 return ret;12895 -1 }12896 -112897 -1 function doWrite(stream, state, writev, len, chunk, encoding, cb) {12898 -1 state.writelen = len;12899 -1 state.writecb = cb;12900 -1 state.writing = true;12901 -1 state.sync = true;12902 -1 if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);12903 -1 state.sync = false;12904 -1 }12905 -112906 -1 function onwriteError(stream, state, sync, er, cb) {12907 -1 --state.pendingcb;12908 -112909 -1 if (sync) {12910 -1 // defer the callback if we are being called synchronously12911 -1 // to avoid piling up things on the stack12912 -1 process.nextTick(cb, er); // this can emit finish, and it will always happen12913 -1 // after error12914 -112915 -1 process.nextTick(finishMaybe, stream, state);12916 -1 stream._writableState.errorEmitted = true;12917 -1 errorOrDestroy(stream, er);12918 -1 } else {12919 -1 // the caller expect this to happen before if12920 -1 // it is async12921 -1 cb(er);12922 -1 stream._writableState.errorEmitted = true;12923 -1 errorOrDestroy(stream, er); // this can emit finish, but finish must12924 -1 // always follow error12925 -112926 -1 finishMaybe(stream, state);12927 -1 }12928 -1 }12929 -112930 -1 function onwriteStateUpdate(state) {12931 -1 state.writing = false;12932 -1 state.writecb = null;12933 -1 state.length -= state.writelen;12934 -1 state.writelen = 0;12935 -1 }12936 -112937 -1 function onwrite(stream, er) {12938 -1 var state = stream._writableState;12939 -1 var sync = state.sync;12940 -1 var cb = state.writecb;12941 -1 if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();12942 -1 onwriteStateUpdate(state);12943 -1 if (er) onwriteError(stream, state, sync, er, cb);else {12944 -1 // Check if we're actually ready to finish, but don't emit yet12945 -1 var finished = needFinish(state) || stream.destroyed;12946 -112947 -1 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {12948 -1 clearBuffer(stream, state);12949 -1 }12950 -112951 -1 if (sync) {12952 -1 process.nextTick(afterWrite, stream, state, finished, cb);12953 -1 } else {12954 -1 afterWrite(stream, state, finished, cb);12955 -1 }12956 -1 }12957 -1 }12958 -112959 -1 function afterWrite(stream, state, finished, cb) {12960 -1 if (!finished) onwriteDrain(stream, state);12961 -1 state.pendingcb--;12962 -1 cb();12963 -1 finishMaybe(stream, state);12964 -1 } // Must force callback to be called on nextTick, so that we don't12965 -1 // emit 'drain' before the write() consumer gets the 'false' return12966 -1 // value, and has a chance to attach a 'drain' listener.12967 -112968 -112969 -1 function onwriteDrain(stream, state) {12970 -1 if (state.length === 0 && state.needDrain) {12971 -1 state.needDrain = false;12972 -1 stream.emit('drain');12973 -1 }12974 -1 } // if there's something in the buffer waiting, then process it12975 -112976 -112977 -1 function clearBuffer(stream, state) {12978 -1 state.bufferProcessing = true;12979 -1 var entry = state.bufferedRequest;12980 -112981 -1 if (stream._writev && entry && entry.next) {12982 -1 // Fast case, write everything using _writev()12983 -1 var l = state.bufferedRequestCount;12984 -1 var buffer = new Array(l);12985 -1 var holder = state.corkedRequestsFree;12986 -1 holder.entry = entry;12987 -1 var count = 0;12988 -1 var allBuffers = true;12989 -112990 -1 while (entry) {12991 -1 buffer[count] = entry;12992 -1 if (!entry.isBuf) allBuffers = false;12993 -1 entry = entry.next;12994 -1 count += 1;12995 -1 }12996 -112997 -1 buffer.allBuffers = allBuffers;12998 -1 doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time12999 -1 // as the hot path ends with doWrite13000 -113001 -1 state.pendingcb++;13002 -1 state.lastBufferedRequest = null;13003 -113004 -1 if (holder.next) {13005 -1 state.corkedRequestsFree = holder.next;13006 -1 holder.next = null;13007 -1 } else {13008 -1 state.corkedRequestsFree = new CorkedRequest(state);13009 -1 }13010 -113011 -1 state.bufferedRequestCount = 0;13012 -1 } else {13013 -1 // Slow case, write chunks one-by-one13014 -1 while (entry) {13015 -1 var chunk = entry.chunk;13016 -1 var encoding = entry.encoding;13017 -1 var cb = entry.callback;13018 -1 var len = state.objectMode ? 1 : chunk.length;13019 -1 doWrite(stream, state, false, len, chunk, encoding, cb);13020 -1 entry = entry.next;13021 -1 state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then13022 -1 // it means that we need to wait until it does.13023 -1 // also, that means that the chunk and cb are currently13024 -1 // being processed, so move the buffer counter past them.13025 -113026 -1 if (state.writing) {13027 -1 break;13028 -1 }13029 -1 }13030 -113031 -1 if (entry === null) state.lastBufferedRequest = null;13032 -1 }13033 -113034 -1 state.bufferedRequest = entry;13035 -1 state.bufferProcessing = false;13036 -1 }13037 -113038 -1 Writable.prototype._write = function (chunk, encoding, cb) {13039 -1 cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));13040 -1 };13041 -113042 -1 Writable.prototype._writev = null;13043 -113044 -1 Writable.prototype.end = function (chunk, encoding, cb) {13045 -1 var state = this._writableState;13046 -113047 -1 if (typeof chunk === 'function') {13048 -1 cb = chunk;13049 -1 chunk = null;13050 -1 encoding = null;13051 -1 } else if (typeof encoding === 'function') {13052 -1 cb = encoding;13053 -1 encoding = null;13054 -1 }13055 -113056 -1 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks13057 -113058 -1 if (state.corked) {13059 -1 state.corked = 1;13060 -1 this.uncork();13061 -1 } // ignore unnecessary end() calls.13062 -113063 -113064 -1 if (!state.ending) endWritable(this, state, cb);13065 -1 return this;13066 -1 };13067 -113068 -1 Object.defineProperty(Writable.prototype, 'writableLength', {13069 -1 // making it explicit this property is not enumerable13070 -1 // because otherwise some prototype manipulation in13071 -1 // userland will fail13072 -1 enumerable: false,13073 -1 get: function get() {13074 -1 return this._writableState.length;13075 -1 }13076 -1 });13077 -113078 -1 function needFinish(state) {13079 -1 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;13080 -1 }13081 -113082 -1 function callFinal(stream, state) {13083 -1 stream._final(function (err) {13084 -1 state.pendingcb--;13085 -113086 -1 if (err) {13087 -1 errorOrDestroy(stream, err);13088 -1 }13089 -113090 -1 state.prefinished = true;13091 -1 stream.emit('prefinish');13092 -1 finishMaybe(stream, state);13093 -1 });13094 -1 }13095 -113096 -1 function prefinish(stream, state) {13097 -1 if (!state.prefinished && !state.finalCalled) {13098 -1 if (typeof stream._final === 'function' && !state.destroyed) {13099 -1 state.pendingcb++;13100 -1 state.finalCalled = true;13101 -1 process.nextTick(callFinal, stream, state);13102 -1 } else {13103 -1 state.prefinished = true;13104 -1 stream.emit('prefinish');13105 -1 }13106 -1 }13107 -1 }13108 -113109 -1 function finishMaybe(stream, state) {13110 -1 var need = needFinish(state);13111 -113112 -1 if (need) {13113 -1 prefinish(stream, state);13114 -113115 -1 if (state.pendingcb === 0) {13116 -1 state.finished = true;13117 -1 stream.emit('finish');13118 -113119 -1 if (state.autoDestroy) {13120 -1 // In case of duplex streams we need a way to detect13121 -1 // if the readable side is ready for autoDestroy as well13122 -1 var rState = stream._readableState;13123 -113124 -1 if (!rState || rState.autoDestroy && rState.endEmitted) {13125 -1 stream.destroy();13126 -1 }13127 -1 }13128 -1 }13129 -1 }13130 -113131 -1 return need;13132 -1 }13133 -113134 -1 function endWritable(stream, state, cb) {13135 -1 state.ending = true;13136 -1 finishMaybe(stream, state);13137 -113138 -1 if (cb) {13139 -1 if (state.finished) process.nextTick(cb);else stream.once('finish', cb);13140 -1 }13141 -113142 -1 state.ended = true;13143 -1 stream.writable = false;13144 -1 }13145 -113146 -1 function onCorkedFinish(corkReq, state, err) {13147 -1 var entry = corkReq.entry;13148 -1 corkReq.entry = null;13149 -113150 -1 while (entry) {13151 -1 var cb = entry.callback;13152 -1 state.pendingcb--;13153 -1 cb(err);13154 -1 entry = entry.next;13155 -1 } // reuse the free corkReq.13156 -113157 -113158 -1 state.corkedRequestsFree.next = corkReq;13159 -1 }13160 -113161 -1 Object.defineProperty(Writable.prototype, 'destroyed', {13162 -1 // making it explicit this property is not enumerable13163 -1 // because otherwise some prototype manipulation in13164 -1 // userland will fail13165 -1 enumerable: false,13166 -1 get: function get() {13167 -1 if (this._writableState === undefined) {13168 -1 return false;13169 -1 }13170 -113171 -1 return this._writableState.destroyed;13172 -1 },13173 -1 set: function set(value) {13174 -1 // we ignore the value if the stream13175 -1 // has not been initialized yet13176 -1 if (!this._writableState) {13177 -1 return;13178 -1 } // backward compatibility, the user is explicitly13179 -1 // managing destroyed13180 -113181 -113182 -1 this._writableState.destroyed = value;13183 -1 }13184 -1 });13185 -1 Writable.prototype.destroy = destroyImpl.destroy;13186 -1 Writable.prototype._undestroy = destroyImpl.undestroy;13187 -113188 -1 Writable.prototype._destroy = function (err, cb) {13189 -1 cb(err);13190 -1 };13191 -1 }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})13192 -1 },{"../errors":47,"./_stream_duplex":48,"./internal/streams/destroy":55,"./internal/streams/state":59,"./internal/streams/stream":60,"_process":149,"buffer":63,"inherits":132,"util-deprecate":187}],53:[function(require,module,exports){13193 -1 (function (process){(function (){13194 -1 'use strict';13195 -113196 -1 var _Object$setPrototypeO;13197 -113198 -1 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }13199 -113200 -1 var finished = require('./end-of-stream');13201 -113202 -1 var kLastResolve = Symbol('lastResolve');13203 -1 var kLastReject = Symbol('lastReject');13204 -1 var kError = Symbol('error');13205 -1 var kEnded = Symbol('ended');13206 -1 var kLastPromise = Symbol('lastPromise');13207 -1 var kHandlePromise = Symbol('handlePromise');13208 -1 var kStream = Symbol('stream');13209 -113210 -1 function createIterResult(value, done) {13211 -1 return {13212 -1 value: value,13213 -1 done: done13214 -1 };13215 -1 }13216 -113217 -1 function readAndResolve(iter) {13218 -1 var resolve = iter[kLastResolve];13219 -113220 -1 if (resolve !== null) {13221 -1 var data = iter[kStream].read(); // we defer if data is null13222 -1 // we can be expecting either 'end' or13223 -1 // 'error'13224 -113225 -1 if (data !== null) {13226 -1 iter[kLastPromise] = null;13227 -1 iter[kLastResolve] = null;13228 -1 iter[kLastReject] = null;13229 -1 resolve(createIterResult(data, false));13230 -1 }13231 -1 }13232 -1 }13233 -113234 -1 function onReadable(iter) {13235 -1 // we wait for the next tick, because it might13236 -1 // emit an error with process.nextTick13237 -1 process.nextTick(readAndResolve, iter);13238 -1 }13239 -113240 -1 function wrapForNext(lastPromise, iter) {13241 -1 return function (resolve, reject) {13242 -1 lastPromise.then(function () {13243 -1 if (iter[kEnded]) {13244 -1 resolve(createIterResult(undefined, true));13245 -1 return;13246 -1 }13247 -113248 -1 iter[kHandlePromise](resolve, reject);13249 -1 }, reject);13250 -1 };13251 -1 }13252 -113253 -1 var AsyncIteratorPrototype = Object.getPrototypeOf(function () {});13254 -1 var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {13255 -1 get stream() {13256 -1 return this[kStream];13257 -1 },13258 -113259 -1 next: function next() {13260 -1 var _this = this;13261 -113262 -1 // if we have detected an error in the meanwhile13263 -1 // reject straight away13264 -1 var error = this[kError];13265 -113266 -1 if (error !== null) {13267 -1 return Promise.reject(error);13268 -1 }13269 -113270 -1 if (this[kEnded]) {13271 -1 return Promise.resolve(createIterResult(undefined, true));13272 -1 }13273 -113274 -1 if (this[kStream].destroyed) {13275 -1 // We need to defer via nextTick because if .destroy(err) is13276 -1 // called, the error will be emitted via nextTick, and13277 -1 // we cannot guarantee that there is no error lingering around13278 -1 // waiting to be emitted.13279 -1 return new Promise(function (resolve, reject) {13280 -1 process.nextTick(function () {13281 -1 if (_this[kError]) {13282 -1 reject(_this[kError]);13283 -1 } else {13284 -1 resolve(createIterResult(undefined, true));13285 -1 }13286 -1 });13287 -1 });13288 -1 } // if we have multiple next() calls13289 -1 // we will wait for the previous Promise to finish13290 -1 // this logic is optimized to support for await loops,13291 -1 // where next() is only called once at a time13292 -113293 -113294 -1 var lastPromise = this[kLastPromise];13295 -1 var promise;13296 -113297 -1 if (lastPromise) {13298 -1 promise = new Promise(wrapForNext(lastPromise, this));13299 -1 } else {13300 -1 // fast path needed to support multiple this.push()13301 -1 // without triggering the next() queue13302 -1 var data = this[kStream].read();13303 -113304 -1 if (data !== null) {13305 -1 return Promise.resolve(createIterResult(data, false));13306 -1 }13307 -113308 -1 promise = new Promise(this[kHandlePromise]);13309 -1 }13310 -113311 -1 this[kLastPromise] = promise;13312 -1 return promise;13313 -1 }13314 -1 }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {13315 -1 return this;13316 -1 }), _defineProperty(_Object$setPrototypeO, "return", function _return() {13317 -1 var _this2 = this;13318 -113319 -1 // destroy(err, cb) is a private API13320 -1 // we can guarantee we have that here, because we control the13321 -1 // Readable class this is attached to13322 -1 return new Promise(function (resolve, reject) {13323 -1 _this2[kStream].destroy(null, function (err) {13324 -1 if (err) {13325 -1 reject(err);13326 -1 return;13327 -1 }13328 -113329 -1 resolve(createIterResult(undefined, true));13330 -1 });13331 -1 });13332 -1 }), _Object$setPrototypeO), AsyncIteratorPrototype);13333 -113334 -1 var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {13335 -1 var _Object$create;13336 -113337 -1 var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {13338 -1 value: stream,13339 -1 writable: true13340 -1 }), _defineProperty(_Object$create, kLastResolve, {13341 -1 value: null,13342 -1 writable: true13343 -1 }), _defineProperty(_Object$create, kLastReject, {13344 -1 value: null,13345 -1 writable: true13346 -1 }), _defineProperty(_Object$create, kError, {13347 -1 value: null,13348 -1 writable: true13349 -1 }), _defineProperty(_Object$create, kEnded, {13350 -1 value: stream._readableState.endEmitted,13351 -1 writable: true13352 -1 }), _defineProperty(_Object$create, kHandlePromise, {13353 -1 value: function value(resolve, reject) {13354 -1 var data = iterator[kStream].read();13355 -113356 -1 if (data) {13357 -1 iterator[kLastPromise] = null;13358 -1 iterator[kLastResolve] = null;13359 -1 iterator[kLastReject] = null;13360 -1 resolve(createIterResult(data, false));13361 -1 } else {13362 -1 iterator[kLastResolve] = resolve;13363 -1 iterator[kLastReject] = reject;13364 -1 }13365 -1 },13366 -1 writable: true13367 -1 }), _Object$create));13368 -1 iterator[kLastPromise] = null;13369 -1 finished(stream, function (err) {13370 -1 if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {13371 -1 var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise13372 -1 // returned by next() and store the error13373 -113374 -1 if (reject !== null) {13375 -1 iterator[kLastPromise] = null;13376 -1 iterator[kLastResolve] = null;13377 -1 iterator[kLastReject] = null;13378 -1 reject(err);13379 -1 }13380 -113381 -1 iterator[kError] = err;13382 -1 return;13383 -1 }13384 -113385 -1 var resolve = iterator[kLastResolve];13386 -113387 -1 if (resolve !== null) {13388 -1 iterator[kLastPromise] = null;13389 -1 iterator[kLastResolve] = null;13390 -1 iterator[kLastReject] = null;13391 -1 resolve(createIterResult(undefined, true));13392 -1 }13393 -113394 -1 iterator[kEnded] = true;13395 -1 });13396 -1 stream.on('readable', onReadable.bind(null, iterator));13397 -1 return iterator;13398 -1 };13399 -113400 -1 module.exports = createReadableStreamAsyncIterator;13401 -1 }).call(this)}).call(this,require('_process'))13402 -1 },{"./end-of-stream":56,"_process":149}],54:[function(require,module,exports){13403 -1 'use strict';13404 -113405 -1 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }13406 -113407 -1 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }13408 -113409 -1 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }13410 -113411 -1 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }13412 -113413 -1 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }13414 -113415 -1 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }13416 -113417 -1 var _require = require('buffer'),13418 -1 Buffer = _require.Buffer;13419 -113420 -1 var _require2 = require('util'),13421 -1 inspect = _require2.inspect;13422 -113423 -1 var custom = inspect && inspect.custom || 'inspect';13424 -113425 -1 function copyBuffer(src, target, offset) {13426 -1 Buffer.prototype.copy.call(src, target, offset);13427 -1 }13428 -113429 -1 module.exports =13430 -1 /*#__PURE__*/13431 -1 function () {13432 -1 function BufferList() {13433 -1 _classCallCheck(this, BufferList);13434 -113435 -1 this.head = null;13436 -1 this.tail = null;13437 -1 this.length = 0;13438 -1 }13439 -113440 -1 _createClass(BufferList, [{13441 -1 key: "push",13442 -1 value: function push(v) {13443 -1 var entry = {13444 -1 data: v,13445 -1 next: null13446 -1 };13447 -1 if (this.length > 0) this.tail.next = entry;else this.head = entry;13448 -1 this.tail = entry;13449 -1 ++this.length;13450 -1 }13451 -1 }, {13452 -1 key: "unshift",13453 -1 value: function unshift(v) {13454 -1 var entry = {13455 -1 data: v,13456 -1 next: this.head13457 -1 };13458 -1 if (this.length === 0) this.tail = entry;13459 -1 this.head = entry;13460 -1 ++this.length;13461 -1 }13462 -1 }, {13463 -1 key: "shift",13464 -1 value: function shift() {13465 -1 if (this.length === 0) return;13466 -1 var ret = this.head.data;13467 -1 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;13468 -1 --this.length;13469 -1 return ret;13470 -1 }13471 -1 }, {13472 -1 key: "clear",13473 -1 value: function clear() {13474 -1 this.head = this.tail = null;13475 -1 this.length = 0;13476 -1 }13477 -1 }, {13478 -1 key: "join",13479 -1 value: function join(s) {13480 -1 if (this.length === 0) return '';13481 -1 var p = this.head;13482 -1 var ret = '' + p.data;13483 -113484 -1 while (p = p.next) {13485 -1 ret += s + p.data;13486 -1 }13487 -113488 -1 return ret;13489 -1 }13490 -1 }, {13491 -1 key: "concat",13492 -1 value: function concat(n) {13493 -1 if (this.length === 0) return Buffer.alloc(0);13494 -1 var ret = Buffer.allocUnsafe(n >>> 0);13495 -1 var p = this.head;13496 -1 var i = 0;13497 -113498 -1 while (p) {13499 -1 copyBuffer(p.data, ret, i);13500 -1 i += p.data.length;13501 -1 p = p.next;13502 -1 }13503 -113504 -1 return ret;13505 -1 } // Consumes a specified amount of bytes or characters from the buffered data.13506 -113507 -1 }, {13508 -1 key: "consume",13509 -1 value: function consume(n, hasStrings) {13510 -1 var ret;13511 -113512 -1 if (n < this.head.data.length) {13513 -1 // `slice` is the same for buffers and strings.13514 -1 ret = this.head.data.slice(0, n);13515 -1 this.head.data = this.head.data.slice(n);13516 -1 } else if (n === this.head.data.length) {13517 -1 // First chunk is a perfect match.13518 -1 ret = this.shift();13519 -1 } else {13520 -1 // Result spans more than one buffer.13521 -1 ret = hasStrings ? this._getString(n) : this._getBuffer(n);13522 -1 }13523 -113524 -1 return ret;13525 -1 }13526 -1 }, {13527 -1 key: "first",13528 -1 value: function first() {13529 -1 return this.head.data;13530 -1 } // Consumes a specified amount of characters from the buffered data.13531 -113532 -1 }, {13533 -1 key: "_getString",13534 -1 value: function _getString(n) {13535 -1 var p = this.head;13536 -1 var c = 1;13537 -1 var ret = p.data;13538 -1 n -= ret.length;13539 -113540 -1 while (p = p.next) {13541 -1 var str = p.data;13542 -1 var nb = n > str.length ? str.length : n;13543 -1 if (nb === str.length) ret += str;else ret += str.slice(0, n);13544 -1 n -= nb;13545 -113546 -1 if (n === 0) {13547 -1 if (nb === str.length) {13548 -1 ++c;13549 -1 if (p.next) this.head = p.next;else this.head = this.tail = null;13550 -1 } else {13551 -1 this.head = p;13552 -1 p.data = str.slice(nb);13553 -1 }13554 -113555 -1 break;13556 -1 }13557 -113558 -1 ++c;13559 -1 }13560 -113561 -1 this.length -= c;13562 -1 return ret;13563 -1 } // Consumes a specified amount of bytes from the buffered data.13564 -113565 -1 }, {13566 -1 key: "_getBuffer",13567 -1 value: function _getBuffer(n) {13568 -1 var ret = Buffer.allocUnsafe(n);13569 -1 var p = this.head;13570 -1 var c = 1;13571 -1 p.data.copy(ret);13572 -1 n -= p.data.length;13573 -113574 -1 while (p = p.next) {13575 -1 var buf = p.data;13576 -1 var nb = n > buf.length ? buf.length : n;13577 -1 buf.copy(ret, ret.length - n, 0, nb);13578 -1 n -= nb;13579 -113580 -1 if (n === 0) {13581 -1 if (nb === buf.length) {13582 -1 ++c;13583 -1 if (p.next) this.head = p.next;else this.head = this.tail = null;13584 -1 } else {13585 -1 this.head = p;13586 -1 p.data = buf.slice(nb);13587 -1 }13588 -113589 -1 break;13590 -1 }13591 -113592 -1 ++c;13593 -1 }13594 -113595 -1 this.length -= c;13596 -1 return ret;13597 -1 } // Make sure the linked list only shows the minimal necessary information.13598 -113599 -1 }, {13600 -1 key: custom,13601 -1 value: function value(_, options) {13602 -1 return inspect(this, _objectSpread({}, options, {13603 -1 // Only inspect one level.13604 -1 depth: 0,13605 -1 // It should not recurse.13606 -1 customInspect: false13607 -1 }));13608 -1 }13609 -1 }]);13610 -113611 -1 return BufferList;13612 -1 }();13613 -1 },{"buffer":63,"util":19}],55:[function(require,module,exports){13614 -1 (function (process){(function (){13615 -1 'use strict'; // undocumented cb() API, needed for core, not for public API13616 -113617 -1 function destroy(err, cb) {13618 -1 var _this = this;13619 -113620 -1 var readableDestroyed = this._readableState && this._readableState.destroyed;13621 -1 var writableDestroyed = this._writableState && this._writableState.destroyed;13622 -113623 -1 if (readableDestroyed || writableDestroyed) {13624 -1 if (cb) {13625 -1 cb(err);13626 -1 } else if (err) {13627 -1 if (!this._writableState) {13628 -1 process.nextTick(emitErrorNT, this, err);13629 -1 } else if (!this._writableState.errorEmitted) {13630 -1 this._writableState.errorEmitted = true;13631 -1 process.nextTick(emitErrorNT, this, err);13632 -1 }13633 -1 }13634 -113635 -1 return this;13636 -1 } // we set destroyed to true before firing error callbacks in order13637 -1 // to make it re-entrance safe in case destroy() is called within callbacks13638 -113639 -113640 -1 if (this._readableState) {13641 -1 this._readableState.destroyed = true;13642 -1 } // if this is a duplex stream mark the writable part as destroyed as well13643 -113644 -113645 -1 if (this._writableState) {13646 -1 this._writableState.destroyed = true;13647 -1 }13648 -113649 -1 this._destroy(err || null, function (err) {13650 -1 if (!cb && err) {13651 -1 if (!_this._writableState) {13652 -1 process.nextTick(emitErrorAndCloseNT, _this, err);13653 -1 } else if (!_this._writableState.errorEmitted) {13654 -1 _this._writableState.errorEmitted = true;13655 -1 process.nextTick(emitErrorAndCloseNT, _this, err);13656 -1 } else {13657 -1 process.nextTick(emitCloseNT, _this);13658 -1 }13659 -1 } else if (cb) {13660 -1 process.nextTick(emitCloseNT, _this);13661 -1 cb(err);13662 -1 } else {13663 -1 process.nextTick(emitCloseNT, _this);13664 -1 }13665 -1 });13666 -113667 -1 return this;13668 -1 }13669 -113670 -1 function emitErrorAndCloseNT(self, err) {13671 -1 emitErrorNT(self, err);13672 -1 emitCloseNT(self);13673 -1 }13674 -113675 -1 function emitCloseNT(self) {13676 -1 if (self._writableState && !self._writableState.emitClose) return;13677 -1 if (self._readableState && !self._readableState.emitClose) return;13678 -1 self.emit('close');13679 -1 }13680 -113681 -1 function undestroy() {13682 -1 if (this._readableState) {13683 -1 this._readableState.destroyed = false;13684 -1 this._readableState.reading = false;13685 -1 this._readableState.ended = false;13686 -1 this._readableState.endEmitted = false;13687 -1 }13688 -113689 -1 if (this._writableState) {13690 -1 this._writableState.destroyed = false;13691 -1 this._writableState.ended = false;13692 -1 this._writableState.ending = false;13693 -1 this._writableState.finalCalled = false;13694 -1 this._writableState.prefinished = false;13695 -1 this._writableState.finished = false;13696 -1 this._writableState.errorEmitted = false;13697 -1 }13698 -1 }13699 -113700 -1 function emitErrorNT(self, err) {13701 -1 self.emit('error', err);13702 -1 }13703 -113704 -1 function errorOrDestroy(stream, err) {13705 -1 // We have tests that rely on errors being emitted13706 -1 // in the same tick, so changing this is semver major.13707 -1 // For now when you opt-in to autoDestroy we allow13708 -1 // the error to be emitted nextTick. In a future13709 -1 // semver major update we should change the default to this.13710 -1 var rState = stream._readableState;13711 -1 var wState = stream._writableState;13712 -1 if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);13713 -1 }13714 -113715 -1 module.exports = {13716 -1 destroy: destroy,13717 -1 undestroy: undestroy,13718 -1 errorOrDestroy: errorOrDestroy13719 -1 };13720 -1 }).call(this)}).call(this,require('_process'))13721 -1 },{"_process":149}],56:[function(require,module,exports){13722 -1 // Ported from https://github.com/mafintosh/end-of-stream with13723 -1 // permission from the author, Mathias Buus (@mafintosh).13724 -1 'use strict';13725 -113726 -1 var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE;13727 -113728 -1 function once(callback) {13729 -1 var called = false;13730 -1 return function () {13731 -1 if (called) return;13732 -1 called = true;13733 -113734 -1 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {13735 -1 args[_key] = arguments[_key];13736 -1 }13737 -113738 -1 callback.apply(this, args);13739 -1 };13740 -1 }13741 -113742 -1 function noop() {}13743 -113744 -1 function isRequest(stream) {13745 -1 return stream.setHeader && typeof stream.abort === 'function';13746 -1 }13747 -113748 -1 function eos(stream, opts, callback) {13749 -1 if (typeof opts === 'function') return eos(stream, null, opts);13750 -1 if (!opts) opts = {};13751 -1 callback = once(callback || noop);13752 -1 var readable = opts.readable || opts.readable !== false && stream.readable;13753 -1 var writable = opts.writable || opts.writable !== false && stream.writable;13754 -113755 -1 var onlegacyfinish = function onlegacyfinish() {13756 -1 if (!stream.writable) onfinish();13757 -1 };13758 -113759 -1 var writableEnded = stream._writableState && stream._writableState.finished;13760 -113761 -1 var onfinish = function onfinish() {13762 -1 writable = false;13763 -1 writableEnded = true;13764 -1 if (!readable) callback.call(stream);13765 -1 };13766 -113767 -1 var readableEnded = stream._readableState && stream._readableState.endEmitted;13768 -113769 -1 var onend = function onend() {13770 -1 readable = false;13771 -1 readableEnded = true;13772 -1 if (!writable) callback.call(stream);13773 -1 };13774 -113775 -1 var onerror = function onerror(err) {13776 -1 callback.call(stream, err);13777 -1 };13778 -113779 -1 var onclose = function onclose() {13780 -1 var err;13781 -113782 -1 if (readable && !readableEnded) {13783 -1 if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();13784 -1 return callback.call(stream, err);13785 -1 }13786 -113787 -1 if (writable && !writableEnded) {13788 -1 if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();13789 -1 return callback.call(stream, err);13790 -1 }13791 -1 };13792 -113793 -1 var onrequest = function onrequest() {13794 -1 stream.req.on('finish', onfinish);13795 -1 };13796 -113797 -1 if (isRequest(stream)) {13798 -1 stream.on('complete', onfinish);13799 -1 stream.on('abort', onclose);13800 -1 if (stream.req) onrequest();else stream.on('request', onrequest);13801 -1 } else if (writable && !stream._writableState) {13802 -1 // legacy streams13803 -1 stream.on('end', onlegacyfinish);13804 -1 stream.on('close', onlegacyfinish);13805 -1 }13806 -113807 -1 stream.on('end', onend);13808 -1 stream.on('finish', onfinish);13809 -1 if (opts.error !== false) stream.on('error', onerror);13810 -1 stream.on('close', onclose);13811 -1 return function () {13812 -1 stream.removeListener('complete', onfinish);13813 -1 stream.removeListener('abort', onclose);13814 -1 stream.removeListener('request', onrequest);13815 -1 if (stream.req) stream.req.removeListener('finish', onfinish);13816 -1 stream.removeListener('end', onlegacyfinish);13817 -1 stream.removeListener('close', onlegacyfinish);13818 -1 stream.removeListener('finish', onfinish);13819 -1 stream.removeListener('end', onend);13820 -1 stream.removeListener('error', onerror);13821 -1 stream.removeListener('close', onclose);13822 -1 };13823 -1 }13824 -113825 -1 module.exports = eos;13826 -1 },{"../../../errors":47}],57:[function(require,module,exports){13827 -1 module.exports = function () {13828 -1 throw new Error('Readable.from is not available in the browser')13829 -1 };13830 -113831 -1 },{}],58:[function(require,module,exports){13832 -1 // Ported from https://github.com/mafintosh/pump with13833 -1 // permission from the author, Mathias Buus (@mafintosh).13834 -1 'use strict';13835 -113836 -1 var eos;13837 -113838 -1 function once(callback) {13839 -1 var called = false;13840 -1 return function () {13841 -1 if (called) return;13842 -1 called = true;13843 -1 callback.apply(void 0, arguments);13844 -1 };13845 -1 }13846 -113847 -1 var _require$codes = require('../../../errors').codes,13848 -1 ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,13849 -1 ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;13850 -113851 -1 function noop(err) {13852 -1 // Rethrow the error if it exists to avoid swallowing it13853 -1 if (err) throw err;13854 -1 }13855 -113856 -1 function isRequest(stream) {13857 -1 return stream.setHeader && typeof stream.abort === 'function';13858 -1 }13859 -113860 -1 function destroyer(stream, reading, writing, callback) {13861 -1 callback = once(callback);13862 -1 var closed = false;13863 -1 stream.on('close', function () {13864 -1 closed = true;13865 -1 });13866 -1 if (eos === undefined) eos = require('./end-of-stream');13867 -1 eos(stream, {13868 -1 readable: reading,13869 -1 writable: writing13870 -1 }, function (err) {13871 -1 if (err) return callback(err);13872 -1 closed = true;13873 -1 callback();13874 -1 });13875 -1 var destroyed = false;13876 -1 return function (err) {13877 -1 if (closed) return;13878 -1 if (destroyed) return;13879 -1 destroyed = true; // request.destroy just do .end - .abort is what we want13880 -113881 -1 if (isRequest(stream)) return stream.abort();13882 -1 if (typeof stream.destroy === 'function') return stream.destroy();13883 -1 callback(err || new ERR_STREAM_DESTROYED('pipe'));13884 -1 };13885 -1 }13886 -113887 -1 function call(fn) {13888 -1 fn();13889 -1 }13890 -113891 -1 function pipe(from, to) {13892 -1 return from.pipe(to);13893 -1 }13894 -113895 -1 function popCallback(streams) {13896 -1 if (!streams.length) return noop;13897 -1 if (typeof streams[streams.length - 1] !== 'function') return noop;13898 -1 return streams.pop();13899 -1 }13900 -113901 -1 function pipeline() {13902 -1 for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {13903 -1 streams[_key] = arguments[_key];13904 -1 }13905 -113906 -1 var callback = popCallback(streams);13907 -1 if (Array.isArray(streams[0])) streams = streams[0];13908 -113909 -1 if (streams.length < 2) {13910 -1 throw new ERR_MISSING_ARGS('streams');13911 -1 }13912 -113913 -1 var error;13914 -1 var destroys = streams.map(function (stream, i) {13915 -1 var reading = i < streams.length - 1;13916 -1 var writing = i > 0;13917 -1 return destroyer(stream, reading, writing, function (err) {13918 -1 if (!error) error = err;13919 -1 if (err) destroys.forEach(call);13920 -1 if (reading) return;13921 -1 destroys.forEach(call);13922 -1 callback(error);13923 -1 });13924 -1 });13925 -1 return streams.reduce(pipe);13926 -1 }13927 -113928 -1 module.exports = pipeline;13929 -1 },{"../../../errors":47,"./end-of-stream":56}],59:[function(require,module,exports){13930 -1 'use strict';13931 -113932 -1 var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;13933 -113934 -1 function highWaterMarkFrom(options, isDuplex, duplexKey) {13935 -1 return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;13936 -1 }13937 -113938 -1 function getHighWaterMark(state, options, duplexKey, isDuplex) {13939 -1 var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);13940 -113941 -1 if (hwm != null) {13942 -1 if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {13943 -1 var name = isDuplex ? duplexKey : 'highWaterMark';13944 -1 throw new ERR_INVALID_OPT_VALUE(name, hwm);13945 -1 }13946 -113947 -1 return Math.floor(hwm);13948 -1 } // Default value13949 -113950 -113951 -1 return state.objectMode ? 16 : 16 * 1024;13952 -1 }13953 -113954 -1 module.exports = {13955 -1 getHighWaterMark: getHighWaterMark13956 -1 };13957 -1 },{"../../../errors":47}],60:[function(require,module,exports){13958 -1 module.exports = require('events').EventEmitter;13959 -113960 -1 },{"events":100}],61:[function(require,module,exports){13961 -1 exports = module.exports = require('./lib/_stream_readable.js');13962 -1 exports.Stream = exports;13963 -1 exports.Readable = exports;13964 -1 exports.Writable = require('./lib/_stream_writable.js');13965 -1 exports.Duplex = require('./lib/_stream_duplex.js');13966 -1 exports.Transform = require('./lib/_stream_transform.js');13967 -1 exports.PassThrough = require('./lib/_stream_passthrough.js');13968 -1 exports.finished = require('./lib/internal/streams/end-of-stream.js');13969 -1 exports.pipeline = require('./lib/internal/streams/pipeline.js');13970 -113971 -1 },{"./lib/_stream_duplex.js":48,"./lib/_stream_passthrough.js":49,"./lib/_stream_readable.js":50,"./lib/_stream_transform.js":51,"./lib/_stream_writable.js":52,"./lib/internal/streams/end-of-stream.js":56,"./lib/internal/streams/pipeline.js":58}],62:[function(require,module,exports){13972 -1 (function (Buffer){(function (){13973 -1 module.exports = function xor (a, b) {13974 -1 var length = Math.min(a.length, b.length)13975 -1 var buffer = new Buffer(length)13976 -113977 -1 for (var i = 0; i < length; ++i) {13978 -1 buffer[i] = a[i] ^ b[i]13979 -1 }13980 -113981 -1 return buffer13982 -1 }13983 -113984 -1 }).call(this)}).call(this,require("buffer").Buffer)13985 -1 },{"buffer":63}],63:[function(require,module,exports){13986 -1 (function (Buffer){(function (){13987 -1 /*!13988 -1 * The buffer module from node.js, for the browser.13989 -1 *13990 -1 * @author Feross Aboukhadijeh <https://feross.org>13991 -1 * @license MIT13992 -1 */13993 -1 /* eslint-disable no-proto */13994 -113995 -1 'use strict'13996 -113997 -1 var base64 = require('base64-js')13998 -1 var ieee754 = require('ieee754')13999 -114000 -1 exports.Buffer = Buffer14001 -1 exports.SlowBuffer = SlowBuffer14002 -1 exports.INSPECT_MAX_BYTES = 5014003 -114004 -1 var K_MAX_LENGTH = 0x7fffffff14005 -1 exports.kMaxLength = K_MAX_LENGTH14006 -114007 -1 /**14008 -1 * If `Buffer.TYPED_ARRAY_SUPPORT`:14009 -1 * === true Use Uint8Array implementation (fastest)14010 -1 * === false Print warning and recommend using `buffer` v4.x which has an Object14011 -1 * implementation (most compatible, even IE6)14012 -1 *14013 -1 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,14014 -1 * Opera 11.6+, iOS 4.2+.14015 -1 *14016 -1 * We report that the browser does not support typed arrays if the are not subclassable14017 -1 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`14018 -1 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support14019 -1 * for __proto__ and has a buggy typed array implementation.14020 -1 */14021 -1 Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()14022 -114023 -1 if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&14024 -1 typeof console.error === 'function') {14025 -1 console.error(14026 -1 'This browser lacks typed array (Uint8Array) support which is required by ' +14027 -1 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'14028 -1 )14029 -1 }14030 -114031 -1 function typedArraySupport () {14032 -1 // Can typed array instances can be augmented?14033 -1 try {14034 -1 var arr = new Uint8Array(1)14035 -1 arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }14036 -1 return arr.foo() === 4214037 -1 } catch (e) {14038 -1 return false14039 -1 }14040 -1 }14041 -114042 -1 Object.defineProperty(Buffer.prototype, 'parent', {14043 -1 enumerable: true,14044 -1 get: function () {14045 -1 if (!Buffer.isBuffer(this)) return undefined14046 -1 return this.buffer14047 -1 }14048 -1 })14049 -114050 -1 Object.defineProperty(Buffer.prototype, 'offset', {14051 -1 enumerable: true,14052 -1 get: function () {14053 -1 if (!Buffer.isBuffer(this)) return undefined14054 -1 return this.byteOffset14055 -1 }14056 -1 })14057 -114058 -1 function createBuffer (length) {14059 -1 if (length > K_MAX_LENGTH) {14060 -1 throw new RangeError('The value "' + length + '" is invalid for option "size"')14061 -1 }14062 -1 // Return an augmented `Uint8Array` instance14063 -1 var buf = new Uint8Array(length)14064 -1 buf.__proto__ = Buffer.prototype14065 -1 return buf14066 -1 }14067 -114068 -1 /**14069 -1 * The Buffer constructor returns instances of `Uint8Array` that have their14070 -1 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of14071 -1 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods14072 -1 * and the `Uint8Array` methods. Square bracket notation works as expected -- it14073 -1 * returns a single octet.14074 -1 *14075 -1 * The `Uint8Array` prototype remains unmodified.14076 -1 */14077 -114078 -1 function Buffer (arg, encodingOrOffset, length) {14079 -1 // Common case.14080 -1 if (typeof arg === 'number') {14081 -1 if (typeof encodingOrOffset === 'string') {14082 -1 throw new TypeError(14083 -1 'The "string" argument must be of type string. Received type number'14084 -1 )14085 -1 }14086 -1 return allocUnsafe(arg)14087 -1 }14088 -1 return from(arg, encodingOrOffset, length)14089 -1 }14090 -114091 -1 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/9714092 -1 if (typeof Symbol !== 'undefined' && Symbol.species != null &&14093 -1 Buffer[Symbol.species] === Buffer) {14094 -1 Object.defineProperty(Buffer, Symbol.species, {14095 -1 value: null,14096 -1 configurable: true,14097 -1 enumerable: false,14098 -1 writable: false14099 -1 })14100 -1 }14101 -114102 -1 Buffer.poolSize = 8192 // not used by this implementation14103 -114104 -1 function from (value, encodingOrOffset, length) {14105 -1 if (typeof value === 'string') {14106 -1 return fromString(value, encodingOrOffset)14107 -1 }14108 -114109 -1 if (ArrayBuffer.isView(value)) {14110 -1 return fromArrayLike(value)14111 -1 }14112 -114113 -1 if (value == null) {14114 -1 throw TypeError(14115 -1 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +14116 -1 'or Array-like Object. Received type ' + (typeof value)14117 -1 )14118 -1 }14119 -114120 -1 if (isInstance(value, ArrayBuffer) ||14121 -1 (value && isInstance(value.buffer, ArrayBuffer))) {14122 -1 return fromArrayBuffer(value, encodingOrOffset, length)14123 -1 }14124 -114125 -1 if (typeof value === 'number') {14126 -1 throw new TypeError(14127 -1 'The "value" argument must not be of type number. Received type number'14128 -1 )14129 -1 }14130 -114131 -1 var valueOf = value.valueOf && value.valueOf()14132 -1 if (valueOf != null && valueOf !== value) {14133 -1 return Buffer.from(valueOf, encodingOrOffset, length)14134 -1 }14135 -114136 -1 var b = fromObject(value)14137 -1 if (b) return b14138 -114139 -1 if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&14140 -1 typeof value[Symbol.toPrimitive] === 'function') {14141 -1 return Buffer.from(14142 -1 value[Symbol.toPrimitive]('string'), encodingOrOffset, length14143 -1 )14144 -1 }14145 -114146 -1 throw new TypeError(14147 -1 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +14148 -1 'or Array-like Object. Received type ' + (typeof value)14149 -1 )14150 -1 }14151 -114152 -1 /**14153 -1 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError14154 -1 * if value is a number.14155 -1 * Buffer.from(str[, encoding])14156 -1 * Buffer.from(array)14157 -1 * Buffer.from(buffer)14158 -1 * Buffer.from(arrayBuffer[, byteOffset[, length]])14159 -1 **/14160 -1 Buffer.from = function (value, encodingOrOffset, length) {14161 -1 return from(value, encodingOrOffset, length)14162 -1 }14163 -114164 -1 // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:14165 -1 // https://github.com/feross/buffer/pull/14814166 -1 Buffer.prototype.__proto__ = Uint8Array.prototype14167 -1 Buffer.__proto__ = Uint8Array14168 -114169 -1 function assertSize (size) {14170 -1 if (typeof size !== 'number') {14171 -1 throw new TypeError('"size" argument must be of type number')14172 -1 } else if (size < 0) {14173 -1 throw new RangeError('The value "' + size + '" is invalid for option "size"')14174 -1 }14175 -1 }14176 -114177 -1 function alloc (size, fill, encoding) {14178 -1 assertSize(size)14179 -1 if (size <= 0) {14180 -1 return createBuffer(size)14181 -1 }14182 -1 if (fill !== undefined) {14183 -1 // Only pay attention to encoding if it's a string. This14184 -1 // prevents accidentally sending in a number that would14185 -1 // be interpretted as a start offset.14186 -1 return typeof encoding === 'string'14187 -1 ? createBuffer(size).fill(fill, encoding)14188 -1 : createBuffer(size).fill(fill)14189 -1 }14190 -1 return createBuffer(size)14191 -1 }14192 -114193 -1 /**14194 -1 * Creates a new filled Buffer instance.14195 -1 * alloc(size[, fill[, encoding]])14196 -1 **/14197 -1 Buffer.alloc = function (size, fill, encoding) {14198 -1 return alloc(size, fill, encoding)14199 -1 }14200 -114201 -1 function allocUnsafe (size) {14202 -1 assertSize(size)14203 -1 return createBuffer(size < 0 ? 0 : checked(size) | 0)14204 -1 }14205 -114206 -1 /**14207 -1 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.14208 -1 * */14209 -1 Buffer.allocUnsafe = function (size) {14210 -1 return allocUnsafe(size)14211 -1 }14212 -1 /**14213 -1 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.14214 -1 */14215 -1 Buffer.allocUnsafeSlow = function (size) {14216 -1 return allocUnsafe(size)14217 -1 }14218 -114219 -1 function fromString (string, encoding) {14220 -1 if (typeof encoding !== 'string' || encoding === '') {14221 -1 encoding = 'utf8'14222 -1 }14223 -114224 -1 if (!Buffer.isEncoding(encoding)) {14225 -1 throw new TypeError('Unknown encoding: ' + encoding)14226 -1 }14227 -114228 -1 var length = byteLength(string, encoding) | 014229 -1 var buf = createBuffer(length)14230 -114231 -1 var actual = buf.write(string, encoding)14232 -114233 -1 if (actual !== length) {14234 -1 // Writing a hex string, for example, that contains invalid characters will14235 -1 // cause everything after the first invalid character to be ignored. (e.g.14236 -1 // 'abxxcd' will be treated as 'ab')14237 -1 buf = buf.slice(0, actual)14238 -1 }14239 -114240 -1 return buf14241 -1 }14242 -114243 -1 function fromArrayLike (array) {14244 -1 var length = array.length < 0 ? 0 : checked(array.length) | 014245 -1 var buf = createBuffer(length)14246 -1 for (var i = 0; i < length; i += 1) {14247 -1 buf[i] = array[i] & 25514248 -1 }14249 -1 return buf14250 -1 }14251 -114252 -1 function fromArrayBuffer (array, byteOffset, length) {14253 -1 if (byteOffset < 0 || array.byteLength < byteOffset) {14254 -1 throw new RangeError('"offset" is outside of buffer bounds')14255 -1 }14256 -114257 -1 if (array.byteLength < byteOffset + (length || 0)) {14258 -1 throw new RangeError('"length" is outside of buffer bounds')14259 -1 }14260 -114261 -1 var buf14262 -1 if (byteOffset === undefined && length === undefined) {14263 -1 buf = new Uint8Array(array)14264 -1 } else if (length === undefined) {14265 -1 buf = new Uint8Array(array, byteOffset)14266 -1 } else {14267 -1 buf = new Uint8Array(array, byteOffset, length)14268 -1 }14269 -114270 -1 // Return an augmented `Uint8Array` instance14271 -1 buf.__proto__ = Buffer.prototype14272 -1 return buf14273 -1 }14274 -114275 -1 function fromObject (obj) {14276 -1 if (Buffer.isBuffer(obj)) {14277 -1 var len = checked(obj.length) | 014278 -1 var buf = createBuffer(len)14279 -114280 -1 if (buf.length === 0) {14281 -1 return buf14282 -1 }14283 -114284 -1 obj.copy(buf, 0, 0, len)14285 -1 return buf14286 -1 }14287 -114288 -1 if (obj.length !== undefined) {14289 -1 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {14290 -1 return createBuffer(0)14291 -1 }14292 -1 return fromArrayLike(obj)14293 -1 }14294 -114295 -1 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {14296 -1 return fromArrayLike(obj.data)14297 -1 }14298 -1 }14299 -114300 -1 function checked (length) {14301 -1 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when14302 -1 // length is NaN (which is otherwise coerced to zero.)14303 -1 if (length >= K_MAX_LENGTH) {14304 -1 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +14305 -1 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')14306 -1 }14307 -1 return length | 014308 -1 }14309 -114310 -1 function SlowBuffer (length) {14311 -1 if (+length != length) { // eslint-disable-line eqeqeq14312 -1 length = 014313 -1 }14314 -1 return Buffer.alloc(+length)14315 -1 }14316 -114317 -1 Buffer.isBuffer = function isBuffer (b) {14318 -1 return b != null && b._isBuffer === true &&14319 -1 b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false14320 -1 }14321 -114322 -1 Buffer.compare = function compare (a, b) {14323 -1 if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)14324 -1 if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)14325 -1 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {14326 -1 throw new TypeError(14327 -1 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'14328 -1 )14329 -1 }14330 -114331 -1 if (a === b) return 014332 -114333 -1 var x = a.length14334 -1 var y = b.length14335 -114336 -1 for (var i = 0, len = Math.min(x, y); i < len; ++i) {14337 -1 if (a[i] !== b[i]) {14338 -1 x = a[i]14339 -1 y = b[i]14340 -1 break14341 -1 }14342 -1 }14343 -114344 -1 if (x < y) return -114345 -1 if (y < x) return 114346 -1 return 014347 -1 }14348 -114349 -1 Buffer.isEncoding = function isEncoding (encoding) {14350 -1 switch (String(encoding).toLowerCase()) {14351 -1 case 'hex':14352 -1 case 'utf8':14353 -1 case 'utf-8':14354 -1 case 'ascii':14355 -1 case 'latin1':14356 -1 case 'binary':14357 -1 case 'base64':14358 -1 case 'ucs2':14359 -1 case 'ucs-2':14360 -1 case 'utf16le':14361 -1 case 'utf-16le':14362 -1 return true14363 -1 default:14364 -1 return false14365 -1 }14366 -1 }14367 -114368 -1 Buffer.concat = function concat (list, length) {14369 -1 if (!Array.isArray(list)) {14370 -1 throw new TypeError('"list" argument must be an Array of Buffers')14371 -1 }14372 -114373 -1 if (list.length === 0) {14374 -1 return Buffer.alloc(0)14375 -1 }14376 -114377 -1 var i14378 -1 if (length === undefined) {14379 -1 length = 014380 -1 for (i = 0; i < list.length; ++i) {14381 -1 length += list[i].length14382 -1 }14383 -1 }14384 -114385 -1 var buffer = Buffer.allocUnsafe(length)14386 -1 var pos = 014387 -1 for (i = 0; i < list.length; ++i) {14388 -1 var buf = list[i]14389 -1 if (isInstance(buf, Uint8Array)) {14390 -1 buf = Buffer.from(buf)14391 -1 }14392 -1 if (!Buffer.isBuffer(buf)) {14393 -1 throw new TypeError('"list" argument must be an Array of Buffers')14394 -1 }14395 -1 buf.copy(buffer, pos)14396 -1 pos += buf.length14397 -1 }14398 -1 return buffer14399 -1 }14400 -114401 -1 function byteLength (string, encoding) {14402 -1 if (Buffer.isBuffer(string)) {14403 -1 return string.length14404 -1 }14405 -1 if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {14406 -1 return string.byteLength14407 -1 }14408 -1 if (typeof string !== 'string') {14409 -1 throw new TypeError(14410 -1 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +14411 -1 'Received type ' + typeof string14412 -1 )14413 -1 }14414 -114415 -1 var len = string.length14416 -1 var mustMatch = (arguments.length > 2 && arguments[2] === true)14417 -1 if (!mustMatch && len === 0) return 014418 -114419 -1 // Use a for loop to avoid recursion14420 -1 var loweredCase = false14421 -1 for (;;) {14422 -1 switch (encoding) {14423 -1 case 'ascii':14424 -1 case 'latin1':14425 -1 case 'binary':14426 -1 return len14427 -1 case 'utf8':14428 -1 case 'utf-8':14429 -1 return utf8ToBytes(string).length14430 -1 case 'ucs2':14431 -1 case 'ucs-2':14432 -1 case 'utf16le':14433 -1 case 'utf-16le':14434 -1 return len * 214435 -1 case 'hex':14436 -1 return len >>> 114437 -1 case 'base64':14438 -1 return base64ToBytes(string).length14439 -1 default:14440 -1 if (loweredCase) {14441 -1 return mustMatch ? -1 : utf8ToBytes(string).length // assume utf814442 -1 }14443 -1 encoding = ('' + encoding).toLowerCase()14444 -1 loweredCase = true14445 -1 }14446 -1 }14447 -1 }14448 -1 Buffer.byteLength = byteLength14449 -114450 -1 function slowToString (encoding, start, end) {14451 -1 var loweredCase = false14452 -114453 -1 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only14454 -1 // property of a typed array.14455 -114456 -1 // This behaves neither like String nor Uint8Array in that we set start/end14457 -1 // to their upper/lower bounds if the value passed is out of range.14458 -1 // undefined is handled specially as per ECMA-262 6th Edition,14459 -1 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.14460 -1 if (start === undefined || start < 0) {14461 -1 start = 014462 -1 }14463 -1 // Return early if start > this.length. Done here to prevent potential uint3214464 -1 // coercion fail below.14465 -1 if (start > this.length) {14466 -1 return ''14467 -1 }14468 -114469 -1 if (end === undefined || end > this.length) {14470 -1 end = this.length14471 -1 }14472 -114473 -1 if (end <= 0) {14474 -1 return ''14475 -1 }14476 -114477 -1 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.14478 -1 end >>>= 014479 -1 start >>>= 014480 -114481 -1 if (end <= start) {14482 -1 return ''14483 -1 }14484 -114485 -1 if (!encoding) encoding = 'utf8'14486 -114487 -1 while (true) {14488 -1 switch (encoding) {14489 -1 case 'hex':14490 -1 return hexSlice(this, start, end)14491 -114492 -1 case 'utf8':14493 -1 case 'utf-8':14494 -1 return utf8Slice(this, start, end)14495 -114496 -1 case 'ascii':14497 -1 return asciiSlice(this, start, end)14498 -114499 -1 case 'latin1':14500 -1 case 'binary':14501 -1 return latin1Slice(this, start, end)14502 -114503 -1 case 'base64':14504 -1 return base64Slice(this, start, end)14505 -114506 -1 case 'ucs2':14507 -1 case 'ucs-2':14508 -1 case 'utf16le':14509 -1 case 'utf-16le':14510 -1 return utf16leSlice(this, start, end)14511 -114512 -1 default:14513 -1 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)14514 -1 encoding = (encoding + '').toLowerCase()14515 -1 loweredCase = true14516 -1 }14517 -1 }14518 -1 }14519 -114520 -1 // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)14521 -1 // to detect a Buffer instance. It's not possible to use `instanceof Buffer`14522 -1 // reliably in a browserify context because there could be multiple different14523 -1 // copies of the 'buffer' package in use. This method works even for Buffer14524 -1 // instances that were created from another copy of the `buffer` package.14525 -1 // See: https://github.com/feross/buffer/issues/15414526 -1 Buffer.prototype._isBuffer = true14527 -114528 -1 function swap (b, n, m) {14529 -1 var i = b[n]14530 -1 b[n] = b[m]14531 -1 b[m] = i14532 -1 }14533 -114534 -1 Buffer.prototype.swap16 = function swap16 () {14535 -1 var len = this.length14536 -1 if (len % 2 !== 0) {14537 -1 throw new RangeError('Buffer size must be a multiple of 16-bits')14538 -1 }14539 -1 for (var i = 0; i < len; i += 2) {14540 -1 swap(this, i, i + 1)14541 -1 }14542 -1 return this14543 -1 }14544 -114545 -1 Buffer.prototype.swap32 = function swap32 () {14546 -1 var len = this.length14547 -1 if (len % 4 !== 0) {14548 -1 throw new RangeError('Buffer size must be a multiple of 32-bits')14549 -1 }14550 -1 for (var i = 0; i < len; i += 4) {14551 -1 swap(this, i, i + 3)14552 -1 swap(this, i + 1, i + 2)14553 -1 }14554 -1 return this14555 -1 }14556 -114557 -1 Buffer.prototype.swap64 = function swap64 () {14558 -1 var len = this.length14559 -1 if (len % 8 !== 0) {14560 -1 throw new RangeError('Buffer size must be a multiple of 64-bits')14561 -1 }14562 -1 for (var i = 0; i < len; i += 8) {14563 -1 swap(this, i, i + 7)14564 -1 swap(this, i + 1, i + 6)14565 -1 swap(this, i + 2, i + 5)14566 -1 swap(this, i + 3, i + 4)14567 -1 }14568 -1 return this14569 -1 }14570 -114571 -1 Buffer.prototype.toString = function toString () {14572 -1 var length = this.length14573 -1 if (length === 0) return ''14574 -1 if (arguments.length === 0) return utf8Slice(this, 0, length)14575 -1 return slowToString.apply(this, arguments)14576 -1 }14577 -114578 -1 Buffer.prototype.toLocaleString = Buffer.prototype.toString14579 -114580 -1 Buffer.prototype.equals = function equals (b) {14581 -1 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')14582 -1 if (this === b) return true14583 -1 return Buffer.compare(this, b) === 014584 -1 }14585 -114586 -1 Buffer.prototype.inspect = function inspect () {14587 -1 var str = ''14588 -1 var max = exports.INSPECT_MAX_BYTES14589 -1 str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()14590 -1 if (this.length > max) str += ' ... '14591 -1 return '<Buffer ' + str + '>'14592 -1 }14593 -114594 -1 Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {14595 -1 if (isInstance(target, Uint8Array)) {14596 -1 target = Buffer.from(target, target.offset, target.byteLength)14597 -1 }14598 -1 if (!Buffer.isBuffer(target)) {14599 -1 throw new TypeError(14600 -1 'The "target" argument must be one of type Buffer or Uint8Array. ' +14601 -1 'Received type ' + (typeof target)14602 -1 )14603 -1 }14604 -114605 -1 if (start === undefined) {14606 -1 start = 014607 -1 }14608 -1 if (end === undefined) {14609 -1 end = target ? target.length : 014610 -1 }14611 -1 if (thisStart === undefined) {14612 -1 thisStart = 014613 -1 }14614 -1 if (thisEnd === undefined) {14615 -1 thisEnd = this.length14616 -1 }14617 -114618 -1 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {14619 -1 throw new RangeError('out of range index')14620 -1 }14621 -114622 -1 if (thisStart >= thisEnd && start >= end) {14623 -1 return 014624 -1 }14625 -1 if (thisStart >= thisEnd) {14626 -1 return -114627 -1 }14628 -1 if (start >= end) {14629 -1 return 114630 -1 }14631 -114632 -1 start >>>= 014633 -1 end >>>= 014634 -1 thisStart >>>= 014635 -1 thisEnd >>>= 014636 -114637 -1 if (this === target) return 014638 -114639 -1 var x = thisEnd - thisStart14640 -1 var y = end - start14641 -1 var len = Math.min(x, y)14642 -114643 -1 var thisCopy = this.slice(thisStart, thisEnd)14644 -1 var targetCopy = target.slice(start, end)14645 -114646 -1 for (var i = 0; i < len; ++i) {14647 -1 if (thisCopy[i] !== targetCopy[i]) {14648 -1 x = thisCopy[i]14649 -1 y = targetCopy[i]14650 -1 break14651 -1 }14652 -1 }14653 -114654 -1 if (x < y) return -114655 -1 if (y < x) return 114656 -1 return 014657 -1 }14658 -114659 -1 // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,14660 -1 // OR the last index of `val` in `buffer` at offset <= `byteOffset`.14661 -1 //14662 -1 // Arguments:14663 -1 // - buffer - a Buffer to search14664 -1 // - val - a string, Buffer, or number14665 -1 // - byteOffset - an index into `buffer`; will be clamped to an int3214666 -1 // - encoding - an optional encoding, relevant is val is a string14667 -1 // - dir - true for indexOf, false for lastIndexOf14668 -1 function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {14669 -1 // Empty buffer means no match14670 -1 if (buffer.length === 0) return -114671 -114672 -1 // Normalize byteOffset14673 -1 if (typeof byteOffset === 'string') {14674 -1 encoding = byteOffset14675 -1 byteOffset = 014676 -1 } else if (byteOffset > 0x7fffffff) {14677 -1 byteOffset = 0x7fffffff14678 -1 } else if (byteOffset < -0x80000000) {14679 -1 byteOffset = -0x8000000014680 -1 }14681 -1 byteOffset = +byteOffset // Coerce to Number.14682 -1 if (numberIsNaN(byteOffset)) {14683 -1 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer14684 -1 byteOffset = dir ? 0 : (buffer.length - 1)14685 -1 }14686 -114687 -1 // Normalize byteOffset: negative offsets start from the end of the buffer14688 -1 if (byteOffset < 0) byteOffset = buffer.length + byteOffset14689 -1 if (byteOffset >= buffer.length) {14690 -1 if (dir) return -114691 -1 else byteOffset = buffer.length - 114692 -1 } else if (byteOffset < 0) {14693 -1 if (dir) byteOffset = 014694 -1 else return -114695 -1 }14696 -114697 -1 // Normalize val14698 -1 if (typeof val === 'string') {14699 -1 val = Buffer.from(val, encoding)14700 -1 }14701 -114702 -1 // Finally, search either indexOf (if dir is true) or lastIndexOf14703 -1 if (Buffer.isBuffer(val)) {14704 -1 // Special case: looking for empty string/buffer always fails14705 -1 if (val.length === 0) {14706 -1 return -114707 -1 }14708 -1 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)14709 -1 } else if (typeof val === 'number') {14710 -1 val = val & 0xFF // Search for a byte value [0-255]14711 -1 if (typeof Uint8Array.prototype.indexOf === 'function') {14712 -1 if (dir) {14713 -1 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)14714 -1 } else {14715 -1 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)14716 -1 }14717 -1 }14718 -1 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)14719 -1 }14720 -114721 -1 throw new TypeError('val must be string, number or Buffer')14722 -1 }14723 -114724 -1 function arrayIndexOf (arr, val, byteOffset, encoding, dir) {14725 -1 var indexSize = 114726 -1 var arrLength = arr.length14727 -1 var valLength = val.length14728 -114729 -1 if (encoding !== undefined) {14730 -1 encoding = String(encoding).toLowerCase()14731 -1 if (encoding === 'ucs2' || encoding === 'ucs-2' ||14732 -1 encoding === 'utf16le' || encoding === 'utf-16le') {14733 -1 if (arr.length < 2 || val.length < 2) {14734 -1 return -114735 -1 }14736 -1 indexSize = 214737 -1 arrLength /= 214738 -1 valLength /= 214739 -1 byteOffset /= 214740 -1 }14741 -1 }14742 -114743 -1 function read (buf, i) {14744 -1 if (indexSize === 1) {14745 -1 return buf[i]14746 -1 } else {14747 -1 return buf.readUInt16BE(i * indexSize)14748 -1 }14749 -1 }14750 -114751 -1 var i14752 -1 if (dir) {14753 -1 var foundIndex = -114754 -1 for (i = byteOffset; i < arrLength; i++) {14755 -1 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {14756 -1 if (foundIndex === -1) foundIndex = i14757 -1 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize14758 -1 } else {14759 -1 if (foundIndex !== -1) i -= i - foundIndex14760 -1 foundIndex = -114761 -1 }14762 -1 }14763 -1 } else {14764 -1 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength14765 -1 for (i = byteOffset; i >= 0; i--) {14766 -1 var found = true14767 -1 for (var j = 0; j < valLength; j++) {14768 -1 if (read(arr, i + j) !== read(val, j)) {14769 -1 found = false14770 -1 break14771 -1 }14772 -1 }14773 -1 if (found) return i14774 -1 }14775 -1 }14776 -114777 -1 return -114778 -1 }14779 -114780 -1 Buffer.prototype.includes = function includes (val, byteOffset, encoding) {14781 -1 return this.indexOf(val, byteOffset, encoding) !== -114782 -1 }14783 -114784 -1 Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {14785 -1 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)14786 -1 }14787 -114788 -1 Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {14789 -1 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)14790 -1 }14791 -114792 -1 function hexWrite (buf, string, offset, length) {14793 -1 offset = Number(offset) || 014794 -1 var remaining = buf.length - offset14795 -1 if (!length) {14796 -1 length = remaining14797 -1 } else {14798 -1 length = Number(length)14799 -1 if (length > remaining) {14800 -1 length = remaining14801 -1 }14802 -1 }14803 -114804 -1 var strLen = string.length14805 -114806 -1 if (length > strLen / 2) {14807 -1 length = strLen / 214808 -1 }14809 -1 for (var i = 0; i < length; ++i) {14810 -1 var parsed = parseInt(string.substr(i * 2, 2), 16)14811 -1 if (numberIsNaN(parsed)) return i14812 -1 buf[offset + i] = parsed14813 -1 }14814 -1 return i14815 -1 }14816 -114817 -1 function utf8Write (buf, string, offset, length) {14818 -1 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)14819 -1 }14820 -114821 -1 function asciiWrite (buf, string, offset, length) {14822 -1 return blitBuffer(asciiToBytes(string), buf, offset, length)14823 -1 }14824 -114825 -1 function latin1Write (buf, string, offset, length) {14826 -1 return asciiWrite(buf, string, offset, length)14827 -1 }14828 -114829 -1 function base64Write (buf, string, offset, length) {14830 -1 return blitBuffer(base64ToBytes(string), buf, offset, length)14831 -1 }14832 -114833 -1 function ucs2Write (buf, string, offset, length) {14834 -1 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)14835 -1 }14836 -114837 -1 Buffer.prototype.write = function write (string, offset, length, encoding) {14838 -1 // Buffer#write(string)14839 -1 if (offset === undefined) {14840 -1 encoding = 'utf8'14841 -1 length = this.length14842 -1 offset = 014843 -1 // Buffer#write(string, encoding)14844 -1 } else if (length === undefined && typeof offset === 'string') {14845 -1 encoding = offset14846 -1 length = this.length14847 -1 offset = 014848 -1 // Buffer#write(string, offset[, length][, encoding])14849 -1 } else if (isFinite(offset)) {14850 -1 offset = offset >>> 014851 -1 if (isFinite(length)) {14852 -1 length = length >>> 014853 -1 if (encoding === undefined) encoding = 'utf8'14854 -1 } else {14855 -1 encoding = length14856 -1 length = undefined14857 -1 }14858 -1 } else {14859 -1 throw new Error(14860 -1 'Buffer.write(string, encoding, offset[, length]) is no longer supported'14861 -1 )14862 -1 }14863 -114864 -1 var remaining = this.length - offset14865 -1 if (length === undefined || length > remaining) length = remaining14866 -114867 -1 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {14868 -1 throw new RangeError('Attempt to write outside buffer bounds')14869 -1 }14870 -114871 -1 if (!encoding) encoding = 'utf8'14872 -114873 -1 var loweredCase = false14874 -1 for (;;) {14875 -1 switch (encoding) {14876 -1 case 'hex':14877 -1 return hexWrite(this, string, offset, length)14878 -114879 -1 case 'utf8':14880 -1 case 'utf-8':14881 -1 return utf8Write(this, string, offset, length)14882 -114883 -1 case 'ascii':14884 -1 return asciiWrite(this, string, offset, length)14885 -114886 -1 case 'latin1':14887 -1 case 'binary':14888 -1 return latin1Write(this, string, offset, length)14889 -114890 -1 case 'base64':14891 -1 // Warning: maxLength not taken into account in base64Write14892 -1 return base64Write(this, string, offset, length)14893 -114894 -1 case 'ucs2':14895 -1 case 'ucs-2':14896 -1 case 'utf16le':14897 -1 case 'utf-16le':14898 -1 return ucs2Write(this, string, offset, length)14899 -114900 -1 default:14901 -1 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)14902 -1 encoding = ('' + encoding).toLowerCase()14903 -1 loweredCase = true14904 -1 }14905 -1 }14906 -1 }14907 -114908 -1 Buffer.prototype.toJSON = function toJSON () {14909 -1 return {14910 -1 type: 'Buffer',14911 -1 data: Array.prototype.slice.call(this._arr || this, 0)14912 -1 }14913 -1 }14914 -114915 -1 function base64Slice (buf, start, end) {14916 -1 if (start === 0 && end === buf.length) {14917 -1 return base64.fromByteArray(buf)14918 -1 } else {14919 -1 return base64.fromByteArray(buf.slice(start, end))14920 -1 }14921 -1 }14922 -114923 -1 function utf8Slice (buf, start, end) {14924 -1 end = Math.min(buf.length, end)14925 -1 var res = []14926 -114927 -1 var i = start14928 -1 while (i < end) {14929 -1 var firstByte = buf[i]14930 -1 var codePoint = null14931 -1 var bytesPerSequence = (firstByte > 0xEF) ? 414932 -1 : (firstByte > 0xDF) ? 314933 -1 : (firstByte > 0xBF) ? 214934 -1 : 114935 -114936 -1 if (i + bytesPerSequence <= end) {14937 -1 var secondByte, thirdByte, fourthByte, tempCodePoint14938 -114939 -1 switch (bytesPerSequence) {14940 -1 case 1:14941 -1 if (firstByte < 0x80) {14942 -1 codePoint = firstByte14943 -1 }14944 -1 break14945 -1 case 2:14946 -1 secondByte = buf[i + 1]14947 -1 if ((secondByte & 0xC0) === 0x80) {14948 -1 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)14949 -1 if (tempCodePoint > 0x7F) {14950 -1 codePoint = tempCodePoint14951 -1 }14952 -1 }14953 -1 break14954 -1 case 3:14955 -1 secondByte = buf[i + 1]14956 -1 thirdByte = buf[i + 2]14957 -1 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {14958 -1 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)14959 -1 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {14960 -1 codePoint = tempCodePoint14961 -1 }14962 -1 }14963 -1 break14964 -1 case 4:14965 -1 secondByte = buf[i + 1]14966 -1 thirdByte = buf[i + 2]14967 -1 fourthByte = buf[i + 3]14968 -1 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {14969 -1 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)14970 -1 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {14971 -1 codePoint = tempCodePoint14972 -1 }14973 -1 }14974 -1 }14975 -1 }14976 -114977 -1 if (codePoint === null) {14978 -1 // we did not generate a valid codePoint so insert a14979 -1 // replacement char (U+FFFD) and advance only 1 byte14980 -1 codePoint = 0xFFFD14981 -1 bytesPerSequence = 114982 -1 } else if (codePoint > 0xFFFF) {14983 -1 // encode to utf16 (surrogate pair dance)14984 -1 codePoint -= 0x1000014985 -1 res.push(codePoint >>> 10 & 0x3FF | 0xD800)14986 -1 codePoint = 0xDC00 | codePoint & 0x3FF14987 -1 }14988 -114989 -1 res.push(codePoint)14990 -1 i += bytesPerSequence14991 -1 }14992 -114993 -1 return decodeCodePointsArray(res)14994 -1 }14995 -114996 -1 // Based on http://stackoverflow.com/a/22747272/680742, the browser with14997 -1 // the lowest limit is Chrome, with 0x10000 args.14998 -1 // We go 1 magnitude less, for safety14999 -1 var MAX_ARGUMENTS_LENGTH = 0x100015000 -115001 -1 function decodeCodePointsArray (codePoints) {15002 -1 var len = codePoints.length15003 -1 if (len <= MAX_ARGUMENTS_LENGTH) {15004 -1 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()15005 -1 }15006 -115007 -1 // Decode in chunks to avoid "call stack size exceeded".15008 -1 var res = ''15009 -1 var i = 015010 -1 while (i < len) {15011 -1 res += String.fromCharCode.apply(15012 -1 String,15013 -1 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)15014 -1 )15015 -1 }15016 -1 return res15017 -1 }15018 -115019 -1 function asciiSlice (buf, start, end) {15020 -1 var ret = ''15021 -1 end = Math.min(buf.length, end)15022 -115023 -1 for (var i = start; i < end; ++i) {15024 -1 ret += String.fromCharCode(buf[i] & 0x7F)15025 -1 }15026 -1 return ret15027 -1 }15028 -115029 -1 function latin1Slice (buf, start, end) {15030 -1 var ret = ''15031 -1 end = Math.min(buf.length, end)15032 -115033 -1 for (var i = start; i < end; ++i) {15034 -1 ret += String.fromCharCode(buf[i])15035 -1 }15036 -1 return ret15037 -1 }15038 -115039 -1 function hexSlice (buf, start, end) {15040 -1 var len = buf.length15041 -115042 -1 if (!start || start < 0) start = 015043 -1 if (!end || end < 0 || end > len) end = len15044 -115045 -1 var out = ''15046 -1 for (var i = start; i < end; ++i) {15047 -1 out += toHex(buf[i])15048 -1 }15049 -1 return out15050 -1 }15051 -115052 -1 function utf16leSlice (buf, start, end) {15053 -1 var bytes = buf.slice(start, end)15054 -1 var res = ''15055 -1 for (var i = 0; i < bytes.length; i += 2) {15056 -1 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))15057 -1 }15058 -1 return res15059 -1 }15060 -115061 -1 Buffer.prototype.slice = function slice (start, end) {15062 -1 var len = this.length15063 -1 start = ~~start15064 -1 end = end === undefined ? len : ~~end15065 -115066 -1 if (start < 0) {15067 -1 start += len15068 -1 if (start < 0) start = 015069 -1 } else if (start > len) {15070 -1 start = len15071 -1 }15072 -115073 -1 if (end < 0) {15074 -1 end += len15075 -1 if (end < 0) end = 015076 -1 } else if (end > len) {15077 -1 end = len15078 -1 }15079 -115080 -1 if (end < start) end = start15081 -115082 -1 var newBuf = this.subarray(start, end)15083 -1 // Return an augmented `Uint8Array` instance15084 -1 newBuf.__proto__ = Buffer.prototype15085 -1 return newBuf15086 -1 }15087 -115088 -1 /*15089 -1 * Need to make sure that buffer isn't trying to write out of bounds.15090 -1 */15091 -1 function checkOffset (offset, ext, length) {15092 -1 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')15093 -1 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')15094 -1 }15095 -115096 -1 Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {15097 -1 offset = offset >>> 015098 -1 byteLength = byteLength >>> 015099 -1 if (!noAssert) checkOffset(offset, byteLength, this.length)15100 -115101 -1 var val = this[offset]15102 -1 var mul = 115103 -1 var i = 015104 -1 while (++i < byteLength && (mul *= 0x100)) {15105 -1 val += this[offset + i] * mul15106 -1 }15107 -115108 -1 return val15109 -1 }15110 -115111 -1 Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {15112 -1 offset = offset >>> 015113 -1 byteLength = byteLength >>> 015114 -1 if (!noAssert) {15115 -1 checkOffset(offset, byteLength, this.length)15116 -1 }15117 -115118 -1 var val = this[offset + --byteLength]15119 -1 var mul = 115120 -1 while (byteLength > 0 && (mul *= 0x100)) {15121 -1 val += this[offset + --byteLength] * mul15122 -1 }15123 -115124 -1 return val15125 -1 }15126 -115127 -1 Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {15128 -1 offset = offset >>> 015129 -1 if (!noAssert) checkOffset(offset, 1, this.length)15130 -1 return this[offset]15131 -1 }15132 -115133 -1 Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {15134 -1 offset = offset >>> 015135 -1 if (!noAssert) checkOffset(offset, 2, this.length)15136 -1 return this[offset] | (this[offset + 1] << 8)15137 -1 }15138 -115139 -1 Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {15140 -1 offset = offset >>> 015141 -1 if (!noAssert) checkOffset(offset, 2, this.length)15142 -1 return (this[offset] << 8) | this[offset + 1]15143 -1 }15144 -115145 -1 Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {15146 -1 offset = offset >>> 015147 -1 if (!noAssert) checkOffset(offset, 4, this.length)15148 -115149 -1 return ((this[offset]) |15150 -1 (this[offset + 1] << 8) |15151 -1 (this[offset + 2] << 16)) +15152 -1 (this[offset + 3] * 0x1000000)15153 -1 }15154 -115155 -1 Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {15156 -1 offset = offset >>> 015157 -1 if (!noAssert) checkOffset(offset, 4, this.length)15158 -115159 -1 return (this[offset] * 0x1000000) +15160 -1 ((this[offset + 1] << 16) |15161 -1 (this[offset + 2] << 8) |15162 -1 this[offset + 3])15163 -1 }15164 -115165 -1 Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {15166 -1 offset = offset >>> 015167 -1 byteLength = byteLength >>> 015168 -1 if (!noAssert) checkOffset(offset, byteLength, this.length)15169 -115170 -1 var val = this[offset]15171 -1 var mul = 115172 -1 var i = 015173 -1 while (++i < byteLength && (mul *= 0x100)) {15174 -1 val += this[offset + i] * mul15175 -1 }15176 -1 mul *= 0x8015177 -115178 -1 if (val >= mul) val -= Math.pow(2, 8 * byteLength)15179 -115180 -1 return val15181 -1 }15182 -115183 -1 Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {15184 -1 offset = offset >>> 015185 -1 byteLength = byteLength >>> 015186 -1 if (!noAssert) checkOffset(offset, byteLength, this.length)15187 -115188 -1 var i = byteLength15189 -1 var mul = 115190 -1 var val = this[offset + --i]15191 -1 while (i > 0 && (mul *= 0x100)) {15192 -1 val += this[offset + --i] * mul15193 -1 }15194 -1 mul *= 0x8015195 -115196 -1 if (val >= mul) val -= Math.pow(2, 8 * byteLength)15197 -115198 -1 return val15199 -1 }15200 -115201 -1 Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {15202 -1 offset = offset >>> 015203 -1 if (!noAssert) checkOffset(offset, 1, this.length)15204 -1 if (!(this[offset] & 0x80)) return (this[offset])15205 -1 return ((0xff - this[offset] + 1) * -1)15206 -1 }15207 -115208 -1 Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {15209 -1 offset = offset >>> 015210 -1 if (!noAssert) checkOffset(offset, 2, this.length)15211 -1 var val = this[offset] | (this[offset + 1] << 8)15212 -1 return (val & 0x8000) ? val | 0xFFFF0000 : val15213 -1 }15214 -115215 -1 Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {15216 -1 offset = offset >>> 015217 -1 if (!noAssert) checkOffset(offset, 2, this.length)15218 -1 var val = this[offset + 1] | (this[offset] << 8)15219 -1 return (val & 0x8000) ? val | 0xFFFF0000 : val15220 -1 }15221 -115222 -1 Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {15223 -1 offset = offset >>> 015224 -1 if (!noAssert) checkOffset(offset, 4, this.length)15225 -115226 -1 return (this[offset]) |15227 -1 (this[offset + 1] << 8) |15228 -1 (this[offset + 2] << 16) |15229 -1 (this[offset + 3] << 24)15230 -1 }15231 -115232 -1 Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {15233 -1 offset = offset >>> 015234 -1 if (!noAssert) checkOffset(offset, 4, this.length)15235 -115236 -1 return (this[offset] << 24) |15237 -1 (this[offset + 1] << 16) |15238 -1 (this[offset + 2] << 8) |15239 -1 (this[offset + 3])15240 -1 }15241 -115242 -1 Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {15243 -1 offset = offset >>> 015244 -1 if (!noAssert) checkOffset(offset, 4, this.length)15245 -1 return ieee754.read(this, offset, true, 23, 4)15246 -1 }15247 -115248 -1 Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {15249 -1 offset = offset >>> 015250 -1 if (!noAssert) checkOffset(offset, 4, this.length)15251 -1 return ieee754.read(this, offset, false, 23, 4)15252 -1 }15253 -115254 -1 Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {15255 -1 offset = offset >>> 015256 -1 if (!noAssert) checkOffset(offset, 8, this.length)15257 -1 return ieee754.read(this, offset, true, 52, 8)15258 -1 }15259 -115260 -1 Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {15261 -1 offset = offset >>> 015262 -1 if (!noAssert) checkOffset(offset, 8, this.length)15263 -1 return ieee754.read(this, offset, false, 52, 8)15264 -1 }15265 -115266 -1 function checkInt (buf, value, offset, ext, max, min) {15267 -1 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')15268 -1 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')15269 -1 if (offset + ext > buf.length) throw new RangeError('Index out of range')15270 -1 }15271 -115272 -1 Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {15273 -1 value = +value15274 -1 offset = offset >>> 015275 -1 byteLength = byteLength >>> 015276 -1 if (!noAssert) {15277 -1 var maxBytes = Math.pow(2, 8 * byteLength) - 115278 -1 checkInt(this, value, offset, byteLength, maxBytes, 0)15279 -1 }15280 -115281 -1 var mul = 115282 -1 var i = 015283 -1 this[offset] = value & 0xFF15284 -1 while (++i < byteLength && (mul *= 0x100)) {15285 -1 this[offset + i] = (value / mul) & 0xFF15286 -1 }15287 -115288 -1 return offset + byteLength15289 -1 }15290 -115291 -1 Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {15292 -1 value = +value15293 -1 offset = offset >>> 015294 -1 byteLength = byteLength >>> 015295 -1 if (!noAssert) {15296 -1 var maxBytes = Math.pow(2, 8 * byteLength) - 115297 -1 checkInt(this, value, offset, byteLength, maxBytes, 0)15298 -1 }15299 -115300 -1 var i = byteLength - 115301 -1 var mul = 115302 -1 this[offset + i] = value & 0xFF15303 -1 while (--i >= 0 && (mul *= 0x100)) {15304 -1 this[offset + i] = (value / mul) & 0xFF15305 -1 }15306 -115307 -1 return offset + byteLength15308 -1 }15309 -115310 -1 Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {15311 -1 value = +value15312 -1 offset = offset >>> 015313 -1 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)15314 -1 this[offset] = (value & 0xff)15315 -1 return offset + 115316 -1 }15317 -115318 -1 Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {15319 -1 value = +value15320 -1 offset = offset >>> 015321 -1 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)15322 -1 this[offset] = (value & 0xff)15323 -1 this[offset + 1] = (value >>> 8)15324 -1 return offset + 215325 -1 }15326 -115327 -1 Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {15328 -1 value = +value15329 -1 offset = offset >>> 015330 -1 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)15331 -1 this[offset] = (value >>> 8)15332 -1 this[offset + 1] = (value & 0xff)15333 -1 return offset + 215334 -1 }15335 -115336 -1 Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {15337 -1 value = +value15338 -1 offset = offset >>> 015339 -1 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)15340 -1 this[offset + 3] = (value >>> 24)15341 -1 this[offset + 2] = (value >>> 16)15342 -1 this[offset + 1] = (value >>> 8)15343 -1 this[offset] = (value & 0xff)15344 -1 return offset + 415345 -1 }15346 -115347 -1 Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {15348 -1 value = +value15349 -1 offset = offset >>> 015350 -1 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)15351 -1 this[offset] = (value >>> 24)15352 -1 this[offset + 1] = (value >>> 16)15353 -1 this[offset + 2] = (value >>> 8)15354 -1 this[offset + 3] = (value & 0xff)15355 -1 return offset + 415356 -1 }15357 -115358 -1 Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {15359 -1 value = +value15360 -1 offset = offset >>> 015361 -1 if (!noAssert) {15362 -1 var limit = Math.pow(2, (8 * byteLength) - 1)15363 -115364 -1 checkInt(this, value, offset, byteLength, limit - 1, -limit)15365 -1 }15366 -115367 -1 var i = 015368 -1 var mul = 115369 -1 var sub = 015370 -1 this[offset] = value & 0xFF15371 -1 while (++i < byteLength && (mul *= 0x100)) {15372 -1 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {15373 -1 sub = 115374 -1 }15375 -1 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF15376 -1 }15377 -115378 -1 return offset + byteLength15379 -1 }15380 -115381 -1 Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {15382 -1 value = +value15383 -1 offset = offset >>> 015384 -1 if (!noAssert) {15385 -1 var limit = Math.pow(2, (8 * byteLength) - 1)15386 -115387 -1 checkInt(this, value, offset, byteLength, limit - 1, -limit)15388 -1 }15389 -115390 -1 var i = byteLength - 115391 -1 var mul = 115392 -1 var sub = 015393 -1 this[offset + i] = value & 0xFF15394 -1 while (--i >= 0 && (mul *= 0x100)) {15395 -1 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {15396 -1 sub = 115397 -1 }15398 -1 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF15399 -1 }15400 -115401 -1 return offset + byteLength15402 -1 }15403 -115404 -1 Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {15405 -1 value = +value15406 -1 offset = offset >>> 015407 -1 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)15408 -1 if (value < 0) value = 0xff + value + 115409 -1 this[offset] = (value & 0xff)15410 -1 return offset + 115411 -1 }15412 -115413 -1 Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {15414 -1 value = +value15415 -1 offset = offset >>> 015416 -1 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)15417 -1 this[offset] = (value & 0xff)15418 -1 this[offset + 1] = (value >>> 8)15419 -1 return offset + 215420 -1 }15421 -115422 -1 Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {15423 -1 value = +value15424 -1 offset = offset >>> 015425 -1 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)15426 -1 this[offset] = (value >>> 8)15427 -1 this[offset + 1] = (value & 0xff)15428 -1 return offset + 215429 -1 }15430 -115431 -1 Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {15432 -1 value = +value15433 -1 offset = offset >>> 015434 -1 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)15435 -1 this[offset] = (value & 0xff)15436 -1 this[offset + 1] = (value >>> 8)15437 -1 this[offset + 2] = (value >>> 16)15438 -1 this[offset + 3] = (value >>> 24)15439 -1 return offset + 415440 -1 }15441 -115442 -1 Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {15443 -1 value = +value15444 -1 offset = offset >>> 015445 -1 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)15446 -1 if (value < 0) value = 0xffffffff + value + 115447 -1 this[offset] = (value >>> 24)15448 -1 this[offset + 1] = (value >>> 16)15449 -1 this[offset + 2] = (value >>> 8)15450 -1 this[offset + 3] = (value & 0xff)15451 -1 return offset + 415452 -1 }15453 -115454 -1 function checkIEEE754 (buf, value, offset, ext, max, min) {15455 -1 if (offset + ext > buf.length) throw new RangeError('Index out of range')15456 -1 if (offset < 0) throw new RangeError('Index out of range')15457 -1 }15458 -115459 -1 function writeFloat (buf, value, offset, littleEndian, noAssert) {15460 -1 value = +value15461 -1 offset = offset >>> 015462 -1 if (!noAssert) {15463 -1 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)15464 -1 }15465 -1 ieee754.write(buf, value, offset, littleEndian, 23, 4)15466 -1 return offset + 415467 -1 }15468 -115469 -1 Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {15470 -1 return writeFloat(this, value, offset, true, noAssert)15471 -1 }15472 -115473 -1 Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {15474 -1 return writeFloat(this, value, offset, false, noAssert)15475 -1 }15476 -115477 -1 function writeDouble (buf, value, offset, littleEndian, noAssert) {15478 -1 value = +value15479 -1 offset = offset >>> 015480 -1 if (!noAssert) {15481 -1 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)15482 -1 }15483 -1 ieee754.write(buf, value, offset, littleEndian, 52, 8)15484 -1 return offset + 815485 -1 }15486 -115487 -1 Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {15488 -1 return writeDouble(this, value, offset, true, noAssert)15489 -1 }15490 -115491 -1 Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {15492 -1 return writeDouble(this, value, offset, false, noAssert)15493 -1 }15494 -115495 -1 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)15496 -1 Buffer.prototype.copy = function copy (target, targetStart, start, end) {15497 -1 if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')15498 -1 if (!start) start = 015499 -1 if (!end && end !== 0) end = this.length15500 -1 if (targetStart >= target.length) targetStart = target.length15501 -1 if (!targetStart) targetStart = 015502 -1 if (end > 0 && end < start) end = start15503 -115504 -1 // Copy 0 bytes; we're done15505 -1 if (end === start) return 015506 -1 if (target.length === 0 || this.length === 0) return 015507 -115508 -1 // Fatal error conditions15509 -1 if (targetStart < 0) {15510 -1 throw new RangeError('targetStart out of bounds')15511 -1 }15512 -1 if (start < 0 || start >= this.length) throw new RangeError('Index out of range')15513 -1 if (end < 0) throw new RangeError('sourceEnd out of bounds')15514 -115515 -1 // Are we oob?15516 -1 if (end > this.length) end = this.length15517 -1 if (target.length - targetStart < end - start) {15518 -1 end = target.length - targetStart + start15519 -1 }15520 -115521 -1 var len = end - start15522 -115523 -1 if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {15524 -1 // Use built-in when available, missing from IE1115525 -1 this.copyWithin(targetStart, start, end)15526 -1 } else if (this === target && start < targetStart && targetStart < end) {15527 -1 // descending copy from end15528 -1 for (var i = len - 1; i >= 0; --i) {15529 -1 target[i + targetStart] = this[i + start]15530 -1 }15531 -1 } else {15532 -1 Uint8Array.prototype.set.call(15533 -1 target,15534 -1 this.subarray(start, end),15535 -1 targetStart15536 -1 )15537 -1 }15538 -115539 -1 return len15540 -1 }15541 -115542 -1 // Usage:15543 -1 // buffer.fill(number[, offset[, end]])15544 -1 // buffer.fill(buffer[, offset[, end]])15545 -1 // buffer.fill(string[, offset[, end]][, encoding])15546 -1 Buffer.prototype.fill = function fill (val, start, end, encoding) {15547 -1 // Handle string cases:15548 -1 if (typeof val === 'string') {15549 -1 if (typeof start === 'string') {15550 -1 encoding = start15551 -1 start = 015552 -1 end = this.length15553 -1 } else if (typeof end === 'string') {15554 -1 encoding = end15555 -1 end = this.length15556 -1 }15557 -1 if (encoding !== undefined && typeof encoding !== 'string') {15558 -1 throw new TypeError('encoding must be a string')15559 -1 }15560 -1 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {15561 -1 throw new TypeError('Unknown encoding: ' + encoding)15562 -1 }15563 -1 if (val.length === 1) {15564 -1 var code = val.charCodeAt(0)15565 -1 if ((encoding === 'utf8' && code < 128) ||15566 -1 encoding === 'latin1') {15567 -1 // Fast path: If `val` fits into a single byte, use that numeric value.15568 -1 val = code15569 -1 }15570 -1 }15571 -1 } else if (typeof val === 'number') {15572 -1 val = val & 25515573 -1 }15574 -115575 -1 // Invalid ranges are not set to a default, so can range check early.15576 -1 if (start < 0 || this.length < start || this.length < end) {15577 -1 throw new RangeError('Out of range index')15578 -1 }15579 -115580 -1 if (end <= start) {15581 -1 return this15582 -1 }15583 -115584 -1 start = start >>> 015585 -1 end = end === undefined ? this.length : end >>> 015586 -115587 -1 if (!val) val = 015588 -115589 -1 var i15590 -1 if (typeof val === 'number') {15591 -1 for (i = start; i < end; ++i) {15592 -1 this[i] = val15593 -1 }15594 -1 } else {15595 -1 var bytes = Buffer.isBuffer(val)15596 -1 ? val15597 -1 : Buffer.from(val, encoding)15598 -1 var len = bytes.length15599 -1 if (len === 0) {15600 -1 throw new TypeError('The value "' + val +15601 -1 '" is invalid for argument "value"')15602 -1 }15603 -1 for (i = 0; i < end - start; ++i) {15604 -1 this[i + start] = bytes[i % len]15605 -1 }15606 -1 }15607 -115608 -1 return this15609 -1 }15610 -115611 -1 // HELPER FUNCTIONS15612 -1 // ================15613 -115614 -1 var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g15615 -115616 -1 function base64clean (str) {15617 -1 // Node takes equal signs as end of the Base64 encoding15618 -1 str = str.split('=')[0]15619 -1 // Node strips out invalid characters like \n and \t from the string, base64-js does not15620 -1 str = str.trim().replace(INVALID_BASE64_RE, '')15621 -1 // Node converts strings with length < 2 to ''15622 -1 if (str.length < 2) return ''15623 -1 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not15624 -1 while (str.length % 4 !== 0) {15625 -1 str = str + '='15626 -1 }15627 -1 return str15628 -1 }15629 -115630 -1 function toHex (n) {15631 -1 if (n < 16) return '0' + n.toString(16)15632 -1 return n.toString(16)15633 -1 }15634 -115635 -1 function utf8ToBytes (string, units) {15636 -1 units = units || Infinity15637 -1 var codePoint15638 -1 var length = string.length15639 -1 var leadSurrogate = null15640 -1 var bytes = []15641 -115642 -1 for (var i = 0; i < length; ++i) {15643 -1 codePoint = string.charCodeAt(i)15644 -115645 -1 // is surrogate component15646 -1 if (codePoint > 0xD7FF && codePoint < 0xE000) {15647 -1 // last char was a lead15648 -1 if (!leadSurrogate) {15649 -1 // no lead yet15650 -1 if (codePoint > 0xDBFF) {15651 -1 // unexpected trail15652 -1 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)15653 -1 continue15654 -1 } else if (i + 1 === length) {15655 -1 // unpaired lead15656 -1 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)15657 -1 continue15658 -1 }15659 -115660 -1 // valid lead15661 -1 leadSurrogate = codePoint15662 -115663 -1 continue15664 -1 }15665 -115666 -1 // 2 leads in a row15667 -1 if (codePoint < 0xDC00) {15668 -1 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)15669 -1 leadSurrogate = codePoint15670 -1 continue15671 -1 }15672 -115673 -1 // valid surrogate pair15674 -1 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x1000015675 -1 } else if (leadSurrogate) {15676 -1 // valid bmp char, but last char was a lead15677 -1 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)15678 -1 }15679 -115680 -1 leadSurrogate = null15681 -115682 -1 // encode utf815683 -1 if (codePoint < 0x80) {15684 -1 if ((units -= 1) < 0) break15685 -1 bytes.push(codePoint)15686 -1 } else if (codePoint < 0x800) {15687 -1 if ((units -= 2) < 0) break15688 -1 bytes.push(15689 -1 codePoint >> 0x6 | 0xC0,15690 -1 codePoint & 0x3F | 0x8015691 -1 )15692 -1 } else if (codePoint < 0x10000) {15693 -1 if ((units -= 3) < 0) break15694 -1 bytes.push(15695 -1 codePoint >> 0xC | 0xE0,15696 -1 codePoint >> 0x6 & 0x3F | 0x80,15697 -1 codePoint & 0x3F | 0x8015698 -1 )15699 -1 } else if (codePoint < 0x110000) {15700 -1 if ((units -= 4) < 0) break15701 -1 bytes.push(15702 -1 codePoint >> 0x12 | 0xF0,15703 -1 codePoint >> 0xC & 0x3F | 0x80,15704 -1 codePoint >> 0x6 & 0x3F | 0x80,15705 -1 codePoint & 0x3F | 0x8015706 -1 )15707 -1 } else {15708 -1 throw new Error('Invalid code point')15709 -1 }15710 -1 }15711 -115712 -1 return bytes15713 -1 }15714 -115715 -1 function asciiToBytes (str) {15716 -1 var byteArray = []15717 -1 for (var i = 0; i < str.length; ++i) {15718 -1 // Node's code seems to be doing this and not & 0x7F..15719 -1 byteArray.push(str.charCodeAt(i) & 0xFF)15720 -1 }15721 -1 return byteArray15722 -1 }15723 -115724 -1 function utf16leToBytes (str, units) {15725 -1 var c, hi, lo15726 -1 var byteArray = []15727 -1 for (var i = 0; i < str.length; ++i) {15728 -1 if ((units -= 2) < 0) break15729 -115730 -1 c = str.charCodeAt(i)15731 -1 hi = c >> 815732 -1 lo = c % 25615733 -1 byteArray.push(lo)15734 -1 byteArray.push(hi)15735 -1 }15736 -115737 -1 return byteArray15738 -1 }15739 -115740 -1 function base64ToBytes (str) {15741 -1 return base64.toByteArray(base64clean(str))15742 -1 }15743 -115744 -1 function blitBuffer (src, dst, offset, length) {15745 -1 for (var i = 0; i < length; ++i) {15746 -1 if ((i + offset >= dst.length) || (i >= src.length)) break15747 -1 dst[i + offset] = src[i]15748 -1 }15749 -1 return i15750 -1 }15751 -115752 -1 // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass15753 -1 // the `instanceof` check but they should be treated as of that type.15754 -1 // See: https://github.com/feross/buffer/issues/16615755 -1 function isInstance (obj, type) {15756 -1 return obj instanceof type ||15757 -1 (obj != null && obj.constructor != null && obj.constructor.name != null &&15758 -1 obj.constructor.name === type.name)15759 -1 }15760 -1 function numberIsNaN (obj) {15761 -1 // For IE11 support15762 -1 return obj !== obj // eslint-disable-line no-self-compare15763 -1 }15764 -115765 -1 }).call(this)}).call(this,require("buffer").Buffer)15766 -1 },{"base64-js":16,"buffer":63,"ieee754":131}],64:[function(require,module,exports){15767 -1 var Buffer = require('safe-buffer').Buffer15768 -1 var Transform = require('stream').Transform15769 -1 var StringDecoder = require('string_decoder').StringDecoder15770 -1 var inherits = require('inherits')15771 -115772 -1 function CipherBase (hashMode) {15773 -1 Transform.call(this)15774 -1 this.hashMode = typeof hashMode === 'string'15775 -1 if (this.hashMode) {15776 -1 this[hashMode] = this._finalOrDigest15777 -1 } else {15778 -1 this.final = this._finalOrDigest15779 -1 }15780 -1 if (this._final) {15781 -1 this.__final = this._final15782 -1 this._final = null15783 -1 }15784 -1 this._decoder = null15785 -1 this._encoding = null15786 -1 }15787 -1 inherits(CipherBase, Transform)15788 -115789 -1 CipherBase.prototype.update = function (data, inputEnc, outputEnc) {15790 -1 if (typeof data === 'string') {15791 -1 data = Buffer.from(data, inputEnc)15792 -1 }15793 -115794 -1 var outData = this._update(data)15795 -1 if (this.hashMode) return this15796 -115797 -1 if (outputEnc) {15798 -1 outData = this._toString(outData, outputEnc)15799 -1 }15800 -115801 -1 return outData15802 -1 }15803 -115804 -1 CipherBase.prototype.setAutoPadding = function () {}15805 -1 CipherBase.prototype.getAuthTag = function () {15806 -1 throw new Error('trying to get auth tag in unsupported state')15807 -1 }15808 -115809 -1 CipherBase.prototype.setAuthTag = function () {15810 -1 throw new Error('trying to set auth tag in unsupported state')15811 -1 }15812 -115813 -1 CipherBase.prototype.setAAD = function () {15814 -1 throw new Error('trying to set aad in unsupported state')15815 -1 }15816 -115817 -1 CipherBase.prototype._transform = function (data, _, next) {15818 -1 var err15819 -1 try {15820 -1 if (this.hashMode) {15821 -1 this._update(data)15822 -1 } else {15823 -1 this.push(this._update(data))15824 -1 }15825 -1 } catch (e) {15826 -1 err = e15827 -1 } finally {15828 -1 next(err)15829 -1 }15830 -1 }15831 -1 CipherBase.prototype._flush = function (done) {15832 -1 var err15833 -1 try {15834 -1 this.push(this.__final())15835 -1 } catch (e) {15836 -1 err = e15837 -1 }15838 -115839 -1 done(err)15840 -1 }15841 -1 CipherBase.prototype._finalOrDigest = function (outputEnc) {15842 -1 var outData = this.__final() || Buffer.alloc(0)15843 -1 if (outputEnc) {15844 -1 outData = this._toString(outData, outputEnc, true)15845 -1 }15846 -1 return outData15847 -1 }15848 -115849 -1 CipherBase.prototype._toString = function (value, enc, fin) {15850 -1 if (!this._decoder) {15851 -1 this._decoder = new StringDecoder(enc)15852 -1 this._encoding = enc15853 -1 }15854 -115855 -1 if (this._encoding !== enc) throw new Error('can\'t switch encodings')15856 -115857 -1 var out = this._decoder.write(value)15858 -1 if (fin) {15859 -1 out += this._decoder.end()15860 -1 }15861 -115862 -1 return out15863 -1 }15864 -115865 -1 module.exports = CipherBase15866 -115867 -1 },{"inherits":132,"safe-buffer":160,"stream":170,"string_decoder":185}],65:[function(require,module,exports){15868 -1 (function (Buffer){(function (){15869 -1 var elliptic = require('elliptic')15870 -1 var BN = require('bn.js')15871 -115872 -1 module.exports = function createECDH (curve) {15873 -1 return new ECDH(curve)15874 -1 }15875 -115876 -1 var aliases = {15877 -1 secp256k1: {15878 -1 name: 'secp256k1',15879 -1 byteLength: 3215880 -1 },15881 -1 secp224r1: {15882 -1 name: 'p224',15883 -1 byteLength: 2815884 -1 },15885 -1 prime256v1: {15886 -1 name: 'p256',15887 -1 byteLength: 3215888 -1 },15889 -1 prime192v1: {15890 -1 name: 'p192',15891 -1 byteLength: 2415892 -1 },15893 -1 ed25519: {15894 -1 name: 'ed25519',15895 -1 byteLength: 3215896 -1 },15897 -1 secp384r1: {15898 -1 name: 'p384',15899 -1 byteLength: 4815900 -1 },15901 -1 secp521r1: {15902 -1 name: 'p521',15903 -1 byteLength: 6615904 -1 }15905 -1 }15906 -115907 -1 aliases.p224 = aliases.secp224r115908 -1 aliases.p256 = aliases.secp256r1 = aliases.prime256v115909 -1 aliases.p192 = aliases.secp192r1 = aliases.prime192v115910 -1 aliases.p384 = aliases.secp384r115911 -1 aliases.p521 = aliases.secp521r115912 -115913 -1 function ECDH (curve) {15914 -1 this.curveType = aliases[curve]15915 -1 if (!this.curveType) {15916 -1 this.curveType = {15917 -1 name: curve15918 -1 }15919 -1 }15920 -1 this.curve = new elliptic.ec(this.curveType.name) // eslint-disable-line new-cap15921 -1 this.keys = void 015922 -1 }15923 -115924 -1 ECDH.prototype.generateKeys = function (enc, format) {15925 -1 this.keys = this.curve.genKeyPair()15926 -1 return this.getPublicKey(enc, format)15927 -1 }15928 -115929 -1 ECDH.prototype.computeSecret = function (other, inenc, enc) {15930 -1 inenc = inenc || 'utf8'15931 -1 if (!Buffer.isBuffer(other)) {15932 -1 other = new Buffer(other, inenc)15933 -1 }15934 -1 var otherPub = this.curve.keyFromPublic(other).getPublic()15935 -1 var out = otherPub.mul(this.keys.getPrivate()).getX()15936 -1 return formatReturnValue(out, enc, this.curveType.byteLength)15937 -1 }15938 -115939 -1 ECDH.prototype.getPublicKey = function (enc, format) {15940 -1 var key = this.keys.getPublic(format === 'compressed', true)15941 -1 if (format === 'hybrid') {15942 -1 if (key[key.length - 1] % 2) {15943 -1 key[0] = 715944 -1 } else {15945 -1 key[0] = 615946 -1 }15947 -1 }15948 -1 return formatReturnValue(key, enc)15949 -1 }15950 -115951 -1 ECDH.prototype.getPrivateKey = function (enc) {15952 -1 return formatReturnValue(this.keys.getPrivate(), enc)15953 -1 }15954 -115955 -1 ECDH.prototype.setPublicKey = function (pub, enc) {15956 -1 enc = enc || 'utf8'15957 -1 if (!Buffer.isBuffer(pub)) {15958 -1 pub = new Buffer(pub, enc)15959 -1 }15960 -1 this.keys._importPublic(pub)15961 -1 return this15962 -1 }15963 -115964 -1 ECDH.prototype.setPrivateKey = function (priv, enc) {15965 -1 enc = enc || 'utf8'15966 -1 if (!Buffer.isBuffer(priv)) {15967 -1 priv = new Buffer(priv, enc)15968 -1 }15969 -115970 -1 var _priv = new BN(priv)15971 -1 _priv = _priv.toString(16)15972 -1 this.keys = this.curve.genKeyPair()15973 -1 this.keys._importPrivate(_priv)15974 -1 return this15975 -1 }15976 -115977 -1 function formatReturnValue (bn, enc, len) {15978 -1 if (!Array.isArray(bn)) {15979 -1 bn = bn.toArray()15980 -1 }15981 -1 var buf = new Buffer(bn)15982 -1 if (len && buf.length < len) {15983 -1 var zeros = new Buffer(len - buf.length)15984 -1 zeros.fill(0)15985 -1 buf = Buffer.concat([zeros, buf])15986 -1 }15987 -1 if (!enc) {15988 -1 return buf15989 -1 } else {15990 -1 return buf.toString(enc)15991 -1 }15992 -1 }15993 -115994 -1 }).call(this)}).call(this,require("buffer").Buffer)15995 -1 },{"bn.js":66,"buffer":63,"elliptic":83}],66:[function(require,module,exports){15996 -1 arguments[4][15][0].apply(exports,arguments)15997 -1 },{"buffer":19,"dup":15}],67:[function(require,module,exports){15998 -1 'use strict'15999 -1 var inherits = require('inherits')16000 -1 var MD5 = require('md5.js')16001 -1 var RIPEMD160 = require('ripemd160')16002 -1 var sha = require('sha.js')16003 -1 var Base = require('cipher-base')16004 -116005 -1 function Hash (hash) {16006 -1 Base.call(this, 'digest')16007 -116008 -1 this._hash = hash16009 -1 }16010 -116011 -1 inherits(Hash, Base)16012 -116013 -1 Hash.prototype._update = function (data) {16014 -1 this._hash.update(data)16015 -1 }16016 -116017 -1 Hash.prototype._final = function () {16018 -1 return this._hash.digest()16019 -1 }16020 -116021 -1 module.exports = function createHash (alg) {16022 -1 alg = alg.toLowerCase()16023 -1 if (alg === 'md5') return new MD5()16024 -1 if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160()16025 -116026 -1 return new Hash(sha(alg))16027 -1 }16028 -116029 -1 },{"cipher-base":64,"inherits":132,"md5.js":133,"ripemd160":159,"sha.js":163}],68:[function(require,module,exports){16030 -1 var MD5 = require('md5.js')16031 -116032 -1 module.exports = function (buffer) {16033 -1 return new MD5().update(buffer).digest()16034 -1 }16035 -116036 -1 },{"md5.js":133}],69:[function(require,module,exports){16037 -1 'use strict'16038 -1 var inherits = require('inherits')16039 -1 var Legacy = require('./legacy')16040 -1 var Base = require('cipher-base')16041 -1 var Buffer = require('safe-buffer').Buffer16042 -1 var md5 = require('create-hash/md5')16043 -1 var RIPEMD160 = require('ripemd160')16044 -116045 -1 var sha = require('sha.js')16046 -116047 -1 var ZEROS = Buffer.alloc(128)16048 -116049 -1 function Hmac (alg, key) {16050 -1 Base.call(this, 'digest')16051 -1 if (typeof key === 'string') {16052 -1 key = Buffer.from(key)16053 -1 }16054 -116055 -1 var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 6416056 -116057 -1 this._alg = alg16058 -1 this._key = key16059 -1 if (key.length > blocksize) {16060 -1 var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)16061 -1 key = hash.update(key).digest()16062 -1 } else if (key.length < blocksize) {16063 -1 key = Buffer.concat([key, ZEROS], blocksize)16064 -1 }16065 -116066 -1 var ipad = this._ipad = Buffer.allocUnsafe(blocksize)16067 -1 var opad = this._opad = Buffer.allocUnsafe(blocksize)16068 -116069 -1 for (var i = 0; i < blocksize; i++) {16070 -1 ipad[i] = key[i] ^ 0x3616071 -1 opad[i] = key[i] ^ 0x5C16072 -1 }16073 -1 this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)16074 -1 this._hash.update(ipad)16075 -1 }16076 -116077 -1 inherits(Hmac, Base)16078 -116079 -1 Hmac.prototype._update = function (data) {16080 -1 this._hash.update(data)16081 -1 }16082 -116083 -1 Hmac.prototype._final = function () {16084 -1 var h = this._hash.digest()16085 -1 var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg)16086 -1 return hash.update(this._opad).update(h).digest()16087 -1 }16088 -116089 -1 module.exports = function createHmac (alg, key) {16090 -1 alg = alg.toLowerCase()16091 -1 if (alg === 'rmd160' || alg === 'ripemd160') {16092 -1 return new Hmac('rmd160', key)16093 -1 }16094 -1 if (alg === 'md5') {16095 -1 return new Legacy(md5, key)16096 -1 }16097 -1 return new Hmac(alg, key)16098 -1 }16099 -116100 -1 },{"./legacy":70,"cipher-base":64,"create-hash/md5":68,"inherits":132,"ripemd160":159,"safe-buffer":160,"sha.js":163}],70:[function(require,module,exports){16101 -1 'use strict'16102 -1 var inherits = require('inherits')16103 -1 var Buffer = require('safe-buffer').Buffer16104 -116105 -1 var Base = require('cipher-base')16106 -116107 -1 var ZEROS = Buffer.alloc(128)16108 -1 var blocksize = 6416109 -116110 -1 function Hmac (alg, key) {16111 -1 Base.call(this, 'digest')16112 -1 if (typeof key === 'string') {16113 -1 key = Buffer.from(key)16114 -1 }16115 -116116 -1 this._alg = alg16117 -1 this._key = key16118 -116119 -1 if (key.length > blocksize) {16120 -1 key = alg(key)16121 -1 } else if (key.length < blocksize) {16122 -1 key = Buffer.concat([key, ZEROS], blocksize)16123 -1 }16124 -116125 -1 var ipad = this._ipad = Buffer.allocUnsafe(blocksize)16126 -1 var opad = this._opad = Buffer.allocUnsafe(blocksize)16127 -116128 -1 for (var i = 0; i < blocksize; i++) {16129 -1 ipad[i] = key[i] ^ 0x3616130 -1 opad[i] = key[i] ^ 0x5C16131 -1 }16132 -116133 -1 this._hash = [ipad]16134 -1 }16135 -116136 -1 inherits(Hmac, Base)16137 -116138 -1 Hmac.prototype._update = function (data) {16139 -1 this._hash.push(data)16140 -1 }16141 -116142 -1 Hmac.prototype._final = function () {16143 -1 var h = this._alg(Buffer.concat(this._hash))16144 -1 return this._alg(Buffer.concat([this._opad, h]))16145 -1 }16146 -1 module.exports = Hmac16147 -116148 -1 },{"cipher-base":64,"inherits":132,"safe-buffer":160}],71:[function(require,module,exports){16149 -1 'use strict'16150 -116151 -1 exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes')16152 -1 exports.createHash = exports.Hash = require('create-hash')16153 -1 exports.createHmac = exports.Hmac = require('create-hmac')16154 -116155 -1 var algos = require('browserify-sign/algos')16156 -1 var algoKeys = Object.keys(algos)16157 -1 var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)16158 -1 exports.getHashes = function () {16159 -1 return hashes16160 -1 }16161 -116162 -1 var p = require('pbkdf2')16163 -1 exports.pbkdf2 = p.pbkdf216164 -1 exports.pbkdf2Sync = p.pbkdf2Sync16165 -116166 -1 var aes = require('browserify-cipher')16167 -116168 -1 exports.Cipher = aes.Cipher16169 -1 exports.createCipher = aes.createCipher16170 -1 exports.Cipheriv = aes.Cipheriv16171 -1 exports.createCipheriv = aes.createCipheriv16172 -1 exports.Decipher = aes.Decipher16173 -1 exports.createDecipher = aes.createDecipher16174 -1 exports.Decipheriv = aes.Decipheriv16175 -1 exports.createDecipheriv = aes.createDecipheriv16176 -1 exports.getCiphers = aes.getCiphers16177 -1 exports.listCiphers = aes.listCiphers16178 -116179 -1 var dh = require('diffie-hellman')16180 -116181 -1 exports.DiffieHellmanGroup = dh.DiffieHellmanGroup16182 -1 exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup16183 -1 exports.getDiffieHellman = dh.getDiffieHellman16184 -1 exports.createDiffieHellman = dh.createDiffieHellman16185 -1 exports.DiffieHellman = dh.DiffieHellman16186 -116187 -1 var sign = require('browserify-sign')16188 -116189 -1 exports.createSign = sign.createSign16190 -1 exports.Sign = sign.Sign16191 -1 exports.createVerify = sign.createVerify16192 -1 exports.Verify = sign.Verify16193 -116194 -1 exports.createECDH = require('create-ecdh')16195 -116196 -1 var publicEncrypt = require('public-encrypt')16197 -116198 -1 exports.publicEncrypt = publicEncrypt.publicEncrypt16199 -1 exports.privateEncrypt = publicEncrypt.privateEncrypt16200 -1 exports.publicDecrypt = publicEncrypt.publicDecrypt16201 -1 exports.privateDecrypt = publicEncrypt.privateDecrypt16202 -116203 -1 // the least I can do is make error messages for the rest of the node.js/crypto api.16204 -1 // ;[16205 -1 // 'createCredentials'16206 -1 // ].forEach(function (name) {16207 -1 // exports[name] = function () {16208 -1 // throw new Error([16209 -1 // 'sorry, ' + name + ' is not implemented yet',16210 -1 // 'we accept pull requests',16211 -1 // 'https://github.com/crypto-browserify/crypto-browserify'16212 -1 // ].join('\n'))16213 -1 // }16214 -1 // })16215 -116216 -1 var rf = require('randomfill')16217 -116218 -1 exports.randomFill = rf.randomFill16219 -1 exports.randomFillSync = rf.randomFillSync16220 -116221 -1 exports.createCredentials = function () {16222 -1 throw new Error([16223 -1 'sorry, createCredentials is not implemented yet',16224 -1 'we accept pull requests',16225 -1 'https://github.com/crypto-browserify/crypto-browserify'16226 -1 ].join('\n'))16227 -1 }16228 -116229 -1 exports.constants = {16230 -1 'DH_CHECK_P_NOT_SAFE_PRIME': 2,16231 -1 'DH_CHECK_P_NOT_PRIME': 1,16232 -1 'DH_UNABLE_TO_CHECK_GENERATOR': 4,16233 -1 'DH_NOT_SUITABLE_GENERATOR': 8,16234 -1 'NPN_ENABLED': 1,16235 -1 'ALPN_ENABLED': 1,16236 -1 'RSA_PKCS1_PADDING': 1,16237 -1 'RSA_SSLV23_PADDING': 2,16238 -1 'RSA_NO_PADDING': 3,16239 -1 'RSA_PKCS1_OAEP_PADDING': 4,16240 -1 'RSA_X931_PADDING': 5,16241 -1 'RSA_PKCS1_PSS_PADDING': 6,16242 -1 'POINT_CONVERSION_COMPRESSED': 2,16243 -1 'POINT_CONVERSION_UNCOMPRESSED': 4,16244 -1 'POINT_CONVERSION_HYBRID': 616245 -1 }16246 -116247 -1 },{"browserify-cipher":37,"browserify-sign":44,"browserify-sign/algos":41,"create-ecdh":65,"create-hash":67,"create-hmac":69,"diffie-hellman":78,"pbkdf2":143,"public-encrypt":150,"randombytes":157,"randomfill":158}],72:[function(require,module,exports){16248 -1 'use strict';16249 -116250 -1 exports.utils = require('./des/utils');16251 -1 exports.Cipher = require('./des/cipher');16252 -1 exports.DES = require('./des/des');16253 -1 exports.CBC = require('./des/cbc');16254 -1 exports.EDE = require('./des/ede');16255 -116256 -1 },{"./des/cbc":73,"./des/cipher":74,"./des/des":75,"./des/ede":76,"./des/utils":77}],73:[function(require,module,exports){16257 -1 'use strict';16258 -116259 -1 var assert = require('minimalistic-assert');16260 -1 var inherits = require('inherits');16261 -116262 -1 var proto = {};16263 -116264 -1 function CBCState(iv) {16265 -1 assert.equal(iv.length, 8, 'Invalid IV length');16266 -116267 -1 this.iv = new Array(8);16268 -1 for (var i = 0; i < this.iv.length; i++)16269 -1 this.iv[i] = iv[i];16270 -1 }16271 -116272 -1 function instantiate(Base) {16273 -1 function CBC(options) {16274 -1 Base.call(this, options);16275 -1 this._cbcInit();16276 -1 }16277 -1 inherits(CBC, Base);16278 -116279 -1 var keys = Object.keys(proto);16280 -1 for (var i = 0; i < keys.length; i++) {16281 -1 var key = keys[i];16282 -1 CBC.prototype[key] = proto[key];16283 -1 }16284 -116285 -1 CBC.create = function create(options) {16286 -1 return new CBC(options);16287 -1 };16288 -116289 -1 return CBC;16290 -1 }16291 -116292 -1 exports.instantiate = instantiate;16293 -116294 -1 proto._cbcInit = function _cbcInit() {16295 -1 var state = new CBCState(this.options.iv);16296 -1 this._cbcState = state;16297 -1 };16298 -116299 -1 proto._update = function _update(inp, inOff, out, outOff) {16300 -1 var state = this._cbcState;16301 -1 var superProto = this.constructor.super_.prototype;16302 -116303 -1 var iv = state.iv;16304 -1 if (this.type === 'encrypt') {16305 -1 for (var i = 0; i < this.blockSize; i++)16306 -1 iv[i] ^= inp[inOff + i];16307 -116308 -1 superProto._update.call(this, iv, 0, out, outOff);16309 -116310 -1 for (var i = 0; i < this.blockSize; i++)16311 -1 iv[i] = out[outOff + i];16312 -1 } else {16313 -1 superProto._update.call(this, inp, inOff, out, outOff);16314 -116315 -1 for (var i = 0; i < this.blockSize; i++)16316 -1 out[outOff + i] ^= iv[i];16317 -116318 -1 for (var i = 0; i < this.blockSize; i++)16319 -1 iv[i] = inp[inOff + i];16320 -1 }16321 -1 };16322 -116323 -1 },{"inherits":132,"minimalistic-assert":136}],74:[function(require,module,exports){16324 -1 'use strict';16325 -116326 -1 var assert = require('minimalistic-assert');16327 -116328 -1 function Cipher(options) {16329 -1 this.options = options;16330 -116331 -1 this.type = this.options.type;16332 -1 this.blockSize = 8;16333 -1 this._init();16334 -116335 -1 this.buffer = new Array(this.blockSize);16336 -1 this.bufferOff = 0;16337 -1 }16338 -1 module.exports = Cipher;16339 -116340 -1 Cipher.prototype._init = function _init() {16341 -1 // Might be overrided16342 -1 };16343 -116344 -1 Cipher.prototype.update = function update(data) {16345 -1 if (data.length === 0)16346 -1 return [];16347 -116348 -1 if (this.type === 'decrypt')16349 -1 return this._updateDecrypt(data);16350 -1 else16351 -1 return this._updateEncrypt(data);16352 -1 };16353 -116354 -1 Cipher.prototype._buffer = function _buffer(data, off) {16355 -1 // Append data to buffer16356 -1 var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);16357 -1 for (var i = 0; i < min; i++)16358 -1 this.buffer[this.bufferOff + i] = data[off + i];16359 -1 this.bufferOff += min;16360 -116361 -1 // Shift next16362 -1 return min;16363 -1 };16364 -116365 -1 Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {16366 -1 this._update(this.buffer, 0, out, off);16367 -1 this.bufferOff = 0;16368 -1 return this.blockSize;16369 -1 };16370 -116371 -1 Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {16372 -1 var inputOff = 0;16373 -1 var outputOff = 0;16374 -116375 -1 var count = ((this.bufferOff + data.length) / this.blockSize) | 0;16376 -1 var out = new Array(count * this.blockSize);16377 -116378 -1 if (this.bufferOff !== 0) {16379 -1 inputOff += this._buffer(data, inputOff);16380 -116381 -1 if (this.bufferOff === this.buffer.length)16382 -1 outputOff += this._flushBuffer(out, outputOff);16383 -1 }16384 -116385 -1 // Write blocks16386 -1 var max = data.length - ((data.length - inputOff) % this.blockSize);16387 -1 for (; inputOff < max; inputOff += this.blockSize) {16388 -1 this._update(data, inputOff, out, outputOff);16389 -1 outputOff += this.blockSize;16390 -1 }16391 -116392 -1 // Queue rest16393 -1 for (; inputOff < data.length; inputOff++, this.bufferOff++)16394 -1 this.buffer[this.bufferOff] = data[inputOff];16395 -116396 -1 return out;16397 -1 };16398 -116399 -1 Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {16400 -1 var inputOff = 0;16401 -1 var outputOff = 0;16402 -116403 -1 var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;16404 -1 var out = new Array(count * this.blockSize);16405 -116406 -1 // TODO(indutny): optimize it, this is far from optimal16407 -1 for (; count > 0; count--) {16408 -1 inputOff += this._buffer(data, inputOff);16409 -1 outputOff += this._flushBuffer(out, outputOff);16410 -1 }16411 -116412 -1 // Buffer rest of the input16413 -1 inputOff += this._buffer(data, inputOff);16414 -116415 -1 return out;16416 -1 };16417 -116418 -1 Cipher.prototype.final = function final(buffer) {16419 -1 var first;16420 -1 if (buffer)16421 -1 first = this.update(buffer);16422 -116423 -1 var last;16424 -1 if (this.type === 'encrypt')16425 -1 last = this._finalEncrypt();16426 -1 else16427 -1 last = this._finalDecrypt();16428 -116429 -1 if (first)16430 -1 return first.concat(last);16431 -1 else16432 -1 return last;16433 -1 };16434 -116435 -1 Cipher.prototype._pad = function _pad(buffer, off) {16436 -1 if (off === 0)16437 -1 return false;16438 -116439 -1 while (off < buffer.length)16440 -1 buffer[off++] = 0;16441 -116442 -1 return true;16443 -1 };16444 -116445 -1 Cipher.prototype._finalEncrypt = function _finalEncrypt() {16446 -1 if (!this._pad(this.buffer, this.bufferOff))16447 -1 return [];16448 -116449 -1 var out = new Array(this.blockSize);16450 -1 this._update(this.buffer, 0, out, 0);16451 -1 return out;16452 -1 };16453 -116454 -1 Cipher.prototype._unpad = function _unpad(buffer) {16455 -1 return buffer;16456 -1 };16457 -116458 -1 Cipher.prototype._finalDecrypt = function _finalDecrypt() {16459 -1 assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');16460 -1 var out = new Array(this.blockSize);16461 -1 this._flushBuffer(out, 0);16462 -116463 -1 return this._unpad(out);16464 -1 };16465 -116466 -1 },{"minimalistic-assert":136}],75:[function(require,module,exports){16467 -1 'use strict';16468 -116469 -1 var assert = require('minimalistic-assert');16470 -1 var inherits = require('inherits');16471 -116472 -1 var utils = require('./utils');16473 -1 var Cipher = require('./cipher');16474 -116475 -1 function DESState() {16476 -1 this.tmp = new Array(2);16477 -1 this.keys = null;16478 -1 }16479 -116480 -1 function DES(options) {16481 -1 Cipher.call(this, options);16482 -116483 -1 var state = new DESState();16484 -1 this._desState = state;16485 -116486 -1 this.deriveKeys(state, options.key);16487 -1 }16488 -1 inherits(DES, Cipher);16489 -1 module.exports = DES;16490 -116491 -1 DES.create = function create(options) {16492 -1 return new DES(options);16493 -1 };16494 -116495 -1 var shiftTable = [16496 -1 1, 1, 2, 2, 2, 2, 2, 2,16497 -1 1, 2, 2, 2, 2, 2, 2, 116498 -1 ];16499 -116500 -1 DES.prototype.deriveKeys = function deriveKeys(state, key) {16501 -1 state.keys = new Array(16 * 2);16502 -116503 -1 assert.equal(key.length, this.blockSize, 'Invalid key length');16504 -116505 -1 var kL = utils.readUInt32BE(key, 0);16506 -1 var kR = utils.readUInt32BE(key, 4);16507 -116508 -1 utils.pc1(kL, kR, state.tmp, 0);16509 -1 kL = state.tmp[0];16510 -1 kR = state.tmp[1];16511 -1 for (var i = 0; i < state.keys.length; i += 2) {16512 -1 var shift = shiftTable[i >>> 1];16513 -1 kL = utils.r28shl(kL, shift);16514 -1 kR = utils.r28shl(kR, shift);16515 -1 utils.pc2(kL, kR, state.keys, i);16516 -1 }16517 -1 };16518 -116519 -1 DES.prototype._update = function _update(inp, inOff, out, outOff) {16520 -1 var state = this._desState;16521 -116522 -1 var l = utils.readUInt32BE(inp, inOff);16523 -1 var r = utils.readUInt32BE(inp, inOff + 4);16524 -116525 -1 // Initial Permutation16526 -1 utils.ip(l, r, state.tmp, 0);16527 -1 l = state.tmp[0];16528 -1 r = state.tmp[1];16529 -116530 -1 if (this.type === 'encrypt')16531 -1 this._encrypt(state, l, r, state.tmp, 0);16532 -1 else16533 -1 this._decrypt(state, l, r, state.tmp, 0);16534 -116535 -1 l = state.tmp[0];16536 -1 r = state.tmp[1];16537 -116538 -1 utils.writeUInt32BE(out, l, outOff);16539 -1 utils.writeUInt32BE(out, r, outOff + 4);16540 -1 };16541 -116542 -1 DES.prototype._pad = function _pad(buffer, off) {16543 -1 var value = buffer.length - off;16544 -1 for (var i = off; i < buffer.length; i++)16545 -1 buffer[i] = value;16546 -116547 -1 return true;16548 -1 };16549 -116550 -1 DES.prototype._unpad = function _unpad(buffer) {16551 -1 var pad = buffer[buffer.length - 1];16552 -1 for (var i = buffer.length - pad; i < buffer.length; i++)16553 -1 assert.equal(buffer[i], pad);16554 -116555 -1 return buffer.slice(0, buffer.length - pad);16556 -1 };16557 -116558 -1 DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {16559 -1 var l = lStart;16560 -1 var r = rStart;16561 -116562 -1 // Apply f() x16 times16563 -1 for (var i = 0; i < state.keys.length; i += 2) {16564 -1 var keyL = state.keys[i];16565 -1 var keyR = state.keys[i + 1];16566 -116567 -1 // f(r, k)16568 -1 utils.expand(r, state.tmp, 0);16569 -116570 -1 keyL ^= state.tmp[0];16571 -1 keyR ^= state.tmp[1];16572 -1 var s = utils.substitute(keyL, keyR);16573 -1 var f = utils.permute(s);16574 -116575 -1 var t = r;16576 -1 r = (l ^ f) >>> 0;16577 -1 l = t;16578 -1 }16579 -116580 -1 // Reverse Initial Permutation16581 -1 utils.rip(r, l, out, off);16582 -1 };16583 -116584 -1 DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {16585 -1 var l = rStart;16586 -1 var r = lStart;16587 -116588 -1 // Apply f() x16 times16589 -1 for (var i = state.keys.length - 2; i >= 0; i -= 2) {16590 -1 var keyL = state.keys[i];16591 -1 var keyR = state.keys[i + 1];16592 -116593 -1 // f(r, k)16594 -1 utils.expand(l, state.tmp, 0);16595 -116596 -1 keyL ^= state.tmp[0];16597 -1 keyR ^= state.tmp[1];16598 -1 var s = utils.substitute(keyL, keyR);16599 -1 var f = utils.permute(s);16600 -116601 -1 var t = l;16602 -1 l = (r ^ f) >>> 0;16603 -1 r = t;16604 -1 }16605 -116606 -1 // Reverse Initial Permutation16607 -1 utils.rip(l, r, out, off);16608 -1 };16609 -116610 -1 },{"./cipher":74,"./utils":77,"inherits":132,"minimalistic-assert":136}],76:[function(require,module,exports){16611 -1 'use strict';16612 -116613 -1 var assert = require('minimalistic-assert');16614 -1 var inherits = require('inherits');16615 -116616 -1 var Cipher = require('./cipher');16617 -1 var DES = require('./des');16618 -116619 -1 function EDEState(type, key) {16620 -1 assert.equal(key.length, 24, 'Invalid key length');16621 -116622 -1 var k1 = key.slice(0, 8);16623 -1 var k2 = key.slice(8, 16);16624 -1 var k3 = key.slice(16, 24);16625 -116626 -1 if (type === 'encrypt') {16627 -1 this.ciphers = [16628 -1 DES.create({ type: 'encrypt', key: k1 }),16629 -1 DES.create({ type: 'decrypt', key: k2 }),16630 -1 DES.create({ type: 'encrypt', key: k3 })16631 -1 ];16632 -1 } else {16633 -1 this.ciphers = [16634 -1 DES.create({ type: 'decrypt', key: k3 }),16635 -1 DES.create({ type: 'encrypt', key: k2 }),16636 -1 DES.create({ type: 'decrypt', key: k1 })16637 -1 ];16638 -1 }16639 -1 }16640 -116641 -1 function EDE(options) {16642 -1 Cipher.call(this, options);16643 -116644 -1 var state = new EDEState(this.type, this.options.key);16645 -1 this._edeState = state;16646 -1 }16647 -1 inherits(EDE, Cipher);16648 -116649 -1 module.exports = EDE;16650 -116651 -1 EDE.create = function create(options) {16652 -1 return new EDE(options);16653 -1 };16654 -116655 -1 EDE.prototype._update = function _update(inp, inOff, out, outOff) {16656 -1 var state = this._edeState;16657 -116658 -1 state.ciphers[0]._update(inp, inOff, out, outOff);16659 -1 state.ciphers[1]._update(out, outOff, out, outOff);16660 -1 state.ciphers[2]._update(out, outOff, out, outOff);16661 -1 };16662 -116663 -1 EDE.prototype._pad = DES.prototype._pad;16664 -1 EDE.prototype._unpad = DES.prototype._unpad;16665 -116666 -1 },{"./cipher":74,"./des":75,"inherits":132,"minimalistic-assert":136}],77:[function(require,module,exports){16667 -1 'use strict';16668 -116669 -1 exports.readUInt32BE = function readUInt32BE(bytes, off) {16670 -1 var res = (bytes[0 + off] << 24) |16671 -1 (bytes[1 + off] << 16) |16672 -1 (bytes[2 + off] << 8) |16673 -1 bytes[3 + off];16674 -1 return res >>> 0;16675 -1 };16676 -116677 -1 exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {16678 -1 bytes[0 + off] = value >>> 24;16679 -1 bytes[1 + off] = (value >>> 16) & 0xff;16680 -1 bytes[2 + off] = (value >>> 8) & 0xff;16681 -1 bytes[3 + off] = value & 0xff;16682 -1 };16683 -116684 -1 exports.ip = function ip(inL, inR, out, off) {16685 -1 var outL = 0;16686 -1 var outR = 0;16687 -116688 -1 for (var i = 6; i >= 0; i -= 2) {16689 -1 for (var j = 0; j <= 24; j += 8) {16690 -1 outL <<= 1;16691 -1 outL |= (inR >>> (j + i)) & 1;16692 -1 }16693 -1 for (var j = 0; j <= 24; j += 8) {16694 -1 outL <<= 1;16695 -1 outL |= (inL >>> (j + i)) & 1;16696 -1 }16697 -1 }16698 -116699 -1 for (var i = 6; i >= 0; i -= 2) {16700 -1 for (var j = 1; j <= 25; j += 8) {16701 -1 outR <<= 1;16702 -1 outR |= (inR >>> (j + i)) & 1;16703 -1 }16704 -1 for (var j = 1; j <= 25; j += 8) {16705 -1 outR <<= 1;16706 -1 outR |= (inL >>> (j + i)) & 1;16707 -1 }16708 -1 }16709 -116710 -1 out[off + 0] = outL >>> 0;16711 -1 out[off + 1] = outR >>> 0;16712 -1 };16713 -116714 -1 exports.rip = function rip(inL, inR, out, off) {16715 -1 var outL = 0;16716 -1 var outR = 0;16717 -116718 -1 for (var i = 0; i < 4; i++) {16719 -1 for (var j = 24; j >= 0; j -= 8) {16720 -1 outL <<= 1;16721 -1 outL |= (inR >>> (j + i)) & 1;16722 -1 outL <<= 1;16723 -1 outL |= (inL >>> (j + i)) & 1;16724 -1 }16725 -1 }16726 -1 for (var i = 4; i < 8; i++) {16727 -1 for (var j = 24; j >= 0; j -= 8) {16728 -1 outR <<= 1;16729 -1 outR |= (inR >>> (j + i)) & 1;16730 -1 outR <<= 1;16731 -1 outR |= (inL >>> (j + i)) & 1;16732 -1 }16733 -1 }16734 -116735 -1 out[off + 0] = outL >>> 0;16736 -1 out[off + 1] = outR >>> 0;16737 -1 };16738 -116739 -1 exports.pc1 = function pc1(inL, inR, out, off) {16740 -1 var outL = 0;16741 -1 var outR = 0;16742 -116743 -1 // 7, 15, 23, 31, 39, 47, 55, 6316744 -1 // 6, 14, 22, 30, 39, 47, 55, 6316745 -1 // 5, 13, 21, 29, 39, 47, 55, 6316746 -1 // 4, 12, 20, 2816747 -1 for (var i = 7; i >= 5; i--) {16748 -1 for (var j = 0; j <= 24; j += 8) {16749 -1 outL <<= 1;16750 -1 outL |= (inR >> (j + i)) & 1;16751 -1 }16752 -1 for (var j = 0; j <= 24; j += 8) {16753 -1 outL <<= 1;16754 -1 outL |= (inL >> (j + i)) & 1;16755 -1 }16756 -1 }16757 -1 for (var j = 0; j <= 24; j += 8) {16758 -1 outL <<= 1;16759 -1 outL |= (inR >> (j + i)) & 1;16760 -1 }16761 -116762 -1 // 1, 9, 17, 25, 33, 41, 49, 5716763 -1 // 2, 10, 18, 26, 34, 42, 50, 5816764 -1 // 3, 11, 19, 27, 35, 43, 51, 5916765 -1 // 36, 44, 52, 6016766 -1 for (var i = 1; i <= 3; i++) {16767 -1 for (var j = 0; j <= 24; j += 8) {16768 -1 outR <<= 1;16769 -1 outR |= (inR >> (j + i)) & 1;16770 -1 }16771 -1 for (var j = 0; j <= 24; j += 8) {16772 -1 outR <<= 1;16773 -1 outR |= (inL >> (j + i)) & 1;16774 -1 }16775 -1 }16776 -1 for (var j = 0; j <= 24; j += 8) {16777 -1 outR <<= 1;16778 -1 outR |= (inL >> (j + i)) & 1;16779 -1 }16780 -116781 -1 out[off + 0] = outL >>> 0;16782 -1 out[off + 1] = outR >>> 0;16783 -1 };16784 -116785 -1 exports.r28shl = function r28shl(num, shift) {16786 -1 return ((num << shift) & 0xfffffff) | (num >>> (28 - shift));16787 -1 };16788 -116789 -1 var pc2table = [16790 -1 // inL => outL16791 -1 14, 11, 17, 4, 27, 23, 25, 0,16792 -1 13, 22, 7, 18, 5, 9, 16, 24,16793 -1 2, 20, 12, 21, 1, 8, 15, 26,16794 -116795 -1 // inR => outR16796 -1 15, 4, 25, 19, 9, 1, 26, 16,16797 -1 5, 11, 23, 8, 12, 7, 17, 0,16798 -1 22, 3, 10, 14, 6, 20, 27, 2416799 -1 ];16800 -116801 -1 exports.pc2 = function pc2(inL, inR, out, off) {16802 -1 var outL = 0;16803 -1 var outR = 0;16804 -116805 -1 var len = pc2table.length >>> 1;16806 -1 for (var i = 0; i < len; i++) {16807 -1 outL <<= 1;16808 -1 outL |= (inL >>> pc2table[i]) & 0x1;16809 -1 }16810 -1 for (var i = len; i < pc2table.length; i++) {16811 -1 outR <<= 1;16812 -1 outR |= (inR >>> pc2table[i]) & 0x1;16813 -1 }16814 -116815 -1 out[off + 0] = outL >>> 0;16816 -1 out[off + 1] = outR >>> 0;16817 -1 };16818 -116819 -1 exports.expand = function expand(r, out, off) {16820 -1 var outL = 0;16821 -1 var outR = 0;16822 -116823 -1 outL = ((r & 1) << 5) | (r >>> 27);16824 -1 for (var i = 23; i >= 15; i -= 4) {16825 -1 outL <<= 6;16826 -1 outL |= (r >>> i) & 0x3f;16827 -1 }16828 -1 for (var i = 11; i >= 3; i -= 4) {16829 -1 outR |= (r >>> i) & 0x3f;16830 -1 outR <<= 6;16831 -1 }16832 -1 outR |= ((r & 0x1f) << 1) | (r >>> 31);16833 -116834 -1 out[off + 0] = outL >>> 0;16835 -1 out[off + 1] = outR >>> 0;16836 -1 };16837 -116838 -1 var sTable = [16839 -1 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1,16840 -1 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8,16841 -1 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7,16842 -1 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13,16843 -116844 -1 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14,16845 -1 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5,16846 -1 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2,16847 -1 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9,16848 -116849 -1 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10,16850 -1 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1,16851 -1 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7,16852 -1 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12,16853 -116854 -1 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3,16855 -1 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9,16856 -1 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8,16857 -1 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14,16858 -116859 -1 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1,16860 -1 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6,16861 -1 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13,16862 -1 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3,16863 -116864 -1 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5,16865 -1 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8,16866 -1 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10,16867 -1 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13,16868 -116869 -1 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10,16870 -1 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6,16871 -1 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7,16872 -1 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12,16873 -116874 -1 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4,16875 -1 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2,16876 -1 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13,16877 -1 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 1116878 -1 ];16879 -116880 -1 exports.substitute = function substitute(inL, inR) {16881 -1 var out = 0;16882 -1 for (var i = 0; i < 4; i++) {16883 -1 var b = (inL >>> (18 - i * 6)) & 0x3f;16884 -1 var sb = sTable[i * 0x40 + b];16885 -116886 -1 out <<= 4;16887 -1 out |= sb;16888 -1 }16889 -1 for (var i = 0; i < 4; i++) {16890 -1 var b = (inR >>> (18 - i * 6)) & 0x3f;16891 -1 var sb = sTable[4 * 0x40 + i * 0x40 + b];16892 -116893 -1 out <<= 4;16894 -1 out |= sb;16895 -1 }16896 -1 return out >>> 0;16897 -1 };16898 -116899 -1 var permuteTable = [16900 -1 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22,16901 -1 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 716902 -1 ];16903 -116904 -1 exports.permute = function permute(num) {16905 -1 var out = 0;16906 -1 for (var i = 0; i < permuteTable.length; i++) {16907 -1 out <<= 1;16908 -1 out |= (num >>> permuteTable[i]) & 0x1;16909 -1 }16910 -1 return out >>> 0;16911 -1 };16912 -116913 -1 exports.padSplit = function padSplit(num, size, group) {16914 -1 var str = num.toString(2);16915 -1 while (str.length < size)16916 -1 str = '0' + str;16917 -116918 -1 var out = [];16919 -1 for (var i = 0; i < size; i += group)16920 -1 out.push(str.slice(i, i + group));16921 -1 return out.join(' ');16922 -1 };16923 -116924 -1 },{}],78:[function(require,module,exports){16925 -1 (function (Buffer){(function (){16926 -1 var generatePrime = require('./lib/generatePrime')16927 -1 var primes = require('./lib/primes.json')16928 -116929 -1 var DH = require('./lib/dh')16930 -116931 -1 function getDiffieHellman (mod) {16932 -1 var prime = new Buffer(primes[mod].prime, 'hex')16933 -1 var gen = new Buffer(primes[mod].gen, 'hex')16934 -116935 -1 return new DH(prime, gen)16936 -1 }16937 -116938 -1 var ENCODINGS = {16939 -1 'binary': true, 'hex': true, 'base64': true16940 -1 }16941 -116942 -1 function createDiffieHellman (prime, enc, generator, genc) {16943 -1 if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {16944 -1 return createDiffieHellman(prime, 'binary', enc, generator)16945 -1 }16946 -116947 -1 enc = enc || 'binary'16948 -1 genc = genc || 'binary'16949 -1 generator = generator || new Buffer([2])16950 -116951 -1 if (!Buffer.isBuffer(generator)) {16952 -1 generator = new Buffer(generator, genc)16953 -1 }16954 -116955 -1 if (typeof prime === 'number') {16956 -1 return new DH(generatePrime(prime, generator), generator, true)16957 -1 }16958 -116959 -1 if (!Buffer.isBuffer(prime)) {16960 -1 prime = new Buffer(prime, enc)16961 -1 }16962 -116963 -1 return new DH(prime, generator, true)16964 -1 }16965 -116966 -1 exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman16967 -1 exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman16968 -116969 -1 }).call(this)}).call(this,require("buffer").Buffer)16970 -1 },{"./lib/dh":79,"./lib/generatePrime":80,"./lib/primes.json":81,"buffer":63}],79:[function(require,module,exports){16971 -1 (function (Buffer){(function (){16972 -1 var BN = require('bn.js');16973 -1 var MillerRabin = require('miller-rabin');16974 -1 var millerRabin = new MillerRabin();16975 -1 var TWENTYFOUR = new BN(24);16976 -1 var ELEVEN = new BN(11);16977 -1 var TEN = new BN(10);16978 -1 var THREE = new BN(3);16979 -1 var SEVEN = new BN(7);16980 -1 var primes = require('./generatePrime');16981 -1 var randomBytes = require('randombytes');16982 -1 module.exports = DH;16983 -116984 -1 function setPublicKey(pub, enc) {16985 -1 enc = enc || 'utf8';16986 -1 if (!Buffer.isBuffer(pub)) {16987 -1 pub = new Buffer(pub, enc);16988 -1 }16989 -1 this._pub = new BN(pub);16990 -1 return this;16991 -1 }16992 -116993 -1 function setPrivateKey(priv, enc) {16994 -1 enc = enc || 'utf8';16995 -1 if (!Buffer.isBuffer(priv)) {16996 -1 priv = new Buffer(priv, enc);16997 -1 }16998 -1 this._priv = new BN(priv);16999 -1 return this;17000 -1 }17001 -117002 -1 var primeCache = {};17003 -1 function checkPrime(prime, generator) {17004 -1 var gen = generator.toString('hex');17005 -1 var hex = [gen, prime.toString(16)].join('_');17006 -1 if (hex in primeCache) {17007 -1 return primeCache[hex];17008 -1 }17009 -1 var error = 0;17010 -117011 -1 if (prime.isEven() ||17012 -1 !primes.simpleSieve ||17013 -1 !primes.fermatTest(prime) ||17014 -1 !millerRabin.test(prime)) {17015 -1 //not a prime so +117016 -1 error += 1;17017 -117018 -1 if (gen === '02' || gen === '05') {17019 -1 // we'd be able to check the generator17020 -1 // it would fail so +817021 -1 error += 8;17022 -1 } else {17023 -1 //we wouldn't be able to test the generator17024 -1 // so +417025 -1 error += 4;17026 -1 }17027 -1 primeCache[hex] = error;17028 -1 return error;17029 -1 }17030 -1 if (!millerRabin.test(prime.shrn(1))) {17031 -1 //not a safe prime17032 -1 error += 2;17033 -1 }17034 -1 var rem;17035 -1 switch (gen) {17036 -1 case '02':17037 -1 if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {17038 -1 // unsuidable generator17039 -1 error += 8;17040 -1 }17041 -1 break;17042 -1 case '05':17043 -1 rem = prime.mod(TEN);17044 -1 if (rem.cmp(THREE) && rem.cmp(SEVEN)) {17045 -1 // prime mod 10 needs to equal 3 or 717046 -1 error += 8;17047 -1 }17048 -1 break;17049 -1 default:17050 -1 error += 4;17051 -1 }17052 -1 primeCache[hex] = error;17053 -1 return error;17054 -1 }17055 -117056 -1 function DH(prime, generator, malleable) {17057 -1 this.setGenerator(generator);17058 -1 this.__prime = new BN(prime);17059 -1 this._prime = BN.mont(this.__prime);17060 -1 this._primeLen = prime.length;17061 -1 this._pub = undefined;17062 -1 this._priv = undefined;17063 -1 this._primeCode = undefined;17064 -1 if (malleable) {17065 -1 this.setPublicKey = setPublicKey;17066 -1 this.setPrivateKey = setPrivateKey;17067 -1 } else {17068 -1 this._primeCode = 8;17069 -1 }17070 -1 }17071 -1 Object.defineProperty(DH.prototype, 'verifyError', {17072 -1 enumerable: true,17073 -1 get: function () {17074 -1 if (typeof this._primeCode !== 'number') {17075 -1 this._primeCode = checkPrime(this.__prime, this.__gen);17076 -1 }17077 -1 return this._primeCode;17078 -1 }17079 -1 });17080 -1 DH.prototype.generateKeys = function () {17081 -1 if (!this._priv) {17082 -1 this._priv = new BN(randomBytes(this._primeLen));17083 -1 }17084 -1 this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();17085 -1 return this.getPublicKey();17086 -1 };17087 -117088 -1 DH.prototype.computeSecret = function (other) {17089 -1 other = new BN(other);17090 -1 other = other.toRed(this._prime);17091 -1 var secret = other.redPow(this._priv).fromRed();17092 -1 var out = new Buffer(secret.toArray());17093 -1 var prime = this.getPrime();17094 -1 if (out.length < prime.length) {17095 -1 var front = new Buffer(prime.length - out.length);17096 -1 front.fill(0);17097 -1 out = Buffer.concat([front, out]);17098 -1 }17099 -1 return out;17100 -1 };17101 -117102 -1 DH.prototype.getPublicKey = function getPublicKey(enc) {17103 -1 return formatReturnValue(this._pub, enc);17104 -1 };17105 -117106 -1 DH.prototype.getPrivateKey = function getPrivateKey(enc) {17107 -1 return formatReturnValue(this._priv, enc);17108 -1 };17109 -117110 -1 DH.prototype.getPrime = function (enc) {17111 -1 return formatReturnValue(this.__prime, enc);17112 -1 };17113 -117114 -1 DH.prototype.getGenerator = function (enc) {17115 -1 return formatReturnValue(this._gen, enc);17116 -1 };17117 -117118 -1 DH.prototype.setGenerator = function (gen, enc) {17119 -1 enc = enc || 'utf8';17120 -1 if (!Buffer.isBuffer(gen)) {17121 -1 gen = new Buffer(gen, enc);17122 -1 }17123 -1 this.__gen = gen;17124 -1 this._gen = new BN(gen);17125 -1 return this;17126 -1 };17127 -117128 -1 function formatReturnValue(bn, enc) {17129 -1 var buf = new Buffer(bn.toArray());17130 -1 if (!enc) {17131 -1 return buf;17132 -1 } else {17133 -1 return buf.toString(enc);17134 -1 }17135 -1 }17136 -117137 -1 }).call(this)}).call(this,require("buffer").Buffer)17138 -1 },{"./generatePrime":80,"bn.js":82,"buffer":63,"miller-rabin":134,"randombytes":157}],80:[function(require,module,exports){17139 -1 var randomBytes = require('randombytes');17140 -1 module.exports = findPrime;17141 -1 findPrime.simpleSieve = simpleSieve;17142 -1 findPrime.fermatTest = fermatTest;17143 -1 var BN = require('bn.js');17144 -1 var TWENTYFOUR = new BN(24);17145 -1 var MillerRabin = require('miller-rabin');17146 -1 var millerRabin = new MillerRabin();17147 -1 var ONE = new BN(1);17148 -1 var TWO = new BN(2);17149 -1 var FIVE = new BN(5);17150 -1 var SIXTEEN = new BN(16);17151 -1 var EIGHT = new BN(8);17152 -1 var TEN = new BN(10);17153 -1 var THREE = new BN(3);17154 -1 var SEVEN = new BN(7);17155 -1 var ELEVEN = new BN(11);17156 -1 var FOUR = new BN(4);17157 -1 var TWELVE = new BN(12);17158 -1 var primes = null;17159 -117160 -1 function _getPrimes() {17161 -1 if (primes !== null)17162 -1 return primes;17163 -117164 -1 var limit = 0x100000;17165 -1 var res = [];17166 -1 res[0] = 2;17167 -1 for (var i = 1, k = 3; k < limit; k += 2) {17168 -1 var sqrt = Math.ceil(Math.sqrt(k));17169 -1 for (var j = 0; j < i && res[j] <= sqrt; j++)17170 -1 if (k % res[j] === 0)17171 -1 break;17172 -117173 -1 if (i !== j && res[j] <= sqrt)17174 -1 continue;17175 -117176 -1 res[i++] = k;17177 -1 }17178 -1 primes = res;17179 -1 return res;17180 -1 }17181 -117182 -1 function simpleSieve(p) {17183 -1 var primes = _getPrimes();17184 -117185 -1 for (var i = 0; i < primes.length; i++)17186 -1 if (p.modn(primes[i]) === 0) {17187 -1 if (p.cmpn(primes[i]) === 0) {17188 -1 return true;17189 -1 } else {17190 -1 return false;17191 -1 }17192 -1 }17193 -117194 -1 return true;17195 -1 }17196 -117197 -1 function fermatTest(p) {17198 -1 var red = BN.mont(p);17199 -1 return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;17200 -1 }17201 -117202 -1 function findPrime(bits, gen) {17203 -1 if (bits < 16) {17204 -1 // this is what openssl does17205 -1 if (gen === 2 || gen === 5) {17206 -1 return new BN([0x8c, 0x7b]);17207 -1 } else {17208 -1 return new BN([0x8c, 0x27]);17209 -1 }17210 -1 }17211 -1 gen = new BN(gen);17212 -117213 -1 var num, n2;17214 -117215 -1 while (true) {17216 -1 num = new BN(randomBytes(Math.ceil(bits / 8)));17217 -1 while (num.bitLength() > bits) {17218 -1 num.ishrn(1);17219 -1 }17220 -1 if (num.isEven()) {17221 -1 num.iadd(ONE);17222 -1 }17223 -1 if (!num.testn(1)) {17224 -1 num.iadd(TWO);17225 -1 }17226 -1 if (!gen.cmp(TWO)) {17227 -1 while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {17228 -1 num.iadd(FOUR);17229 -1 }17230 -1 } else if (!gen.cmp(FIVE)) {17231 -1 while (num.mod(TEN).cmp(THREE)) {17232 -1 num.iadd(FOUR);17233 -1 }17234 -1 }17235 -1 n2 = num.shrn(1);17236 -1 if (simpleSieve(n2) && simpleSieve(num) &&17237 -1 fermatTest(n2) && fermatTest(num) &&17238 -1 millerRabin.test(n2) && millerRabin.test(num)) {17239 -1 return num;17240 -1 }17241 -1 }17242 -117243 -1 }17244 -117245 -1 },{"bn.js":82,"miller-rabin":134,"randombytes":157}],81:[function(require,module,exports){17246 -1 module.exports={17247 -1 "modp1": {17248 -1 "gen": "02",17249 -1 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"17250 -1 },17251 -1 "modp2": {17252 -1 "gen": "02",17253 -1 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"17254 -1 },17255 -1 "modp5": {17256 -1 "gen": "02",17257 -1 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"17258 -1 },17259 -1 "modp14": {17260 -1 "gen": "02",17261 -1 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"17262 -1 },17263 -1 "modp15": {17264 -1 "gen": "02",17265 -1 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"17266 -1 },17267 -1 "modp16": {17268 -1 "gen": "02",17269 -1 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"17270 -1 },17271 -1 "modp17": {17272 -1 "gen": "02",17273 -1 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"17274 -1 },17275 -1 "modp18": {17276 -1 "gen": "02",17277 -1 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"17278 -1 }17279 -1 }17280 -1 },{}],82:[function(require,module,exports){17281 -1 arguments[4][15][0].apply(exports,arguments)17282 -1 },{"buffer":19,"dup":15}],83:[function(require,module,exports){17283 -1 'use strict';17284 -117285 -1 var elliptic = exports;17286 -117287 -1 elliptic.version = require('../package.json').version;17288 -1 elliptic.utils = require('./elliptic/utils');17289 -1 elliptic.rand = require('brorand');17290 -1 elliptic.curve = require('./elliptic/curve');17291 -1 elliptic.curves = require('./elliptic/curves');17292 -117293 -1 // Protocols17294 -1 elliptic.ec = require('./elliptic/ec');17295 -1 elliptic.eddsa = require('./elliptic/eddsa');17296 -117297 -1 },{"../package.json":99,"./elliptic/curve":86,"./elliptic/curves":89,"./elliptic/ec":90,"./elliptic/eddsa":93,"./elliptic/utils":97,"brorand":18}],84:[function(require,module,exports){17298 -1 'use strict';17299 -117300 -1 var BN = require('bn.js');17301 -1 var utils = require('../utils');17302 -1 var getNAF = utils.getNAF;17303 -1 var getJSF = utils.getJSF;17304 -1 var assert = utils.assert;17305 -117306 -1 function BaseCurve(type, conf) {17307 -1 this.type = type;17308 -1 this.p = new BN(conf.p, 16);17309 -117310 -1 // Use Montgomery, when there is no fast reduction for the prime17311 -1 this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);17312 -117313 -1 // Useful for many curves17314 -1 this.zero = new BN(0).toRed(this.red);17315 -1 this.one = new BN(1).toRed(this.red);17316 -1 this.two = new BN(2).toRed(this.red);17317 -117318 -1 // Curve configuration, optional17319 -1 this.n = conf.n && new BN(conf.n, 16);17320 -1 this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);17321 -117322 -1 // Temporary arrays17323 -1 this._wnafT1 = new Array(4);17324 -1 this._wnafT2 = new Array(4);17325 -1 this._wnafT3 = new Array(4);17326 -1 this._wnafT4 = new Array(4);17327 -117328 -1 this._bitLength = this.n ? this.n.bitLength() : 0;17329 -117330 -1 // Generalized Greg Maxwell's trick17331 -1 var adjustCount = this.n && this.p.div(this.n);17332 -1 if (!adjustCount || adjustCount.cmpn(100) > 0) {17333 -1 this.redN = null;17334 -1 } else {17335 -1 this._maxwellTrick = true;17336 -1 this.redN = this.n.toRed(this.red);17337 -1 }17338 -1 }17339 -1 module.exports = BaseCurve;17340 -117341 -1 BaseCurve.prototype.point = function point() {17342 -1 throw new Error('Not implemented');17343 -1 };17344 -117345 -1 BaseCurve.prototype.validate = function validate() {17346 -1 throw new Error('Not implemented');17347 -1 };17348 -117349 -1 BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {17350 -1 assert(p.precomputed);17351 -1 var doubles = p._getDoubles();17352 -117353 -1 var naf = getNAF(k, 1, this._bitLength);17354 -1 var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);17355 -1 I /= 3;17356 -117357 -1 // Translate into more windowed form17358 -1 var repr = [];17359 -1 var j;17360 -1 var nafW;17361 -1 for (j = 0; j < naf.length; j += doubles.step) {17362 -1 nafW = 0;17363 -1 for (var l = j + doubles.step - 1; l >= j; l--)17364 -1 nafW = (nafW << 1) + naf[l];17365 -1 repr.push(nafW);17366 -1 }17367 -117368 -1 var a = this.jpoint(null, null, null);17369 -1 var b = this.jpoint(null, null, null);17370 -1 for (var i = I; i > 0; i--) {17371 -1 for (j = 0; j < repr.length; j++) {17372 -1 nafW = repr[j];17373 -1 if (nafW === i)17374 -1 b = b.mixedAdd(doubles.points[j]);17375 -1 else if (nafW === -i)17376 -1 b = b.mixedAdd(doubles.points[j].neg());17377 -1 }17378 -1 a = a.add(b);17379 -1 }17380 -1 return a.toP();17381 -1 };17382 -117383 -1 BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {17384 -1 var w = 4;17385 -117386 -1 // Precompute window17387 -1 var nafPoints = p._getNAFPoints(w);17388 -1 w = nafPoints.wnd;17389 -1 var wnd = nafPoints.points;17390 -117391 -1 // Get NAF form17392 -1 var naf = getNAF(k, w, this._bitLength);17393 -117394 -1 // Add `this`*(N+1) for every w-NAF index17395 -1 var acc = this.jpoint(null, null, null);17396 -1 for (var i = naf.length - 1; i >= 0; i--) {17397 -1 // Count zeroes17398 -1 for (var l = 0; i >= 0 && naf[i] === 0; i--)17399 -1 l++;17400 -1 if (i >= 0)17401 -1 l++;17402 -1 acc = acc.dblp(l);17403 -117404 -1 if (i < 0)17405 -1 break;17406 -1 var z = naf[i];17407 -1 assert(z !== 0);17408 -1 if (p.type === 'affine') {17409 -1 // J +- P17410 -1 if (z > 0)17411 -1 acc = acc.mixedAdd(wnd[(z - 1) >> 1]);17412 -1 else17413 -1 acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());17414 -1 } else {17415 -1 // J +- J17416 -1 if (z > 0)17417 -1 acc = acc.add(wnd[(z - 1) >> 1]);17418 -1 else17419 -1 acc = acc.add(wnd[(-z - 1) >> 1].neg());17420 -1 }17421 -1 }17422 -1 return p.type === 'affine' ? acc.toP() : acc;17423 -1 };17424 -117425 -1 BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,17426 -1 points,17427 -1 coeffs,17428 -1 len,17429 -1 jacobianResult) {17430 -1 var wndWidth = this._wnafT1;17431 -1 var wnd = this._wnafT2;17432 -1 var naf = this._wnafT3;17433 -117434 -1 // Fill all arrays17435 -1 var max = 0;17436 -1 var i;17437 -1 var j;17438 -1 var p;17439 -1 for (i = 0; i < len; i++) {17440 -1 p = points[i];17441 -1 var nafPoints = p._getNAFPoints(defW);17442 -1 wndWidth[i] = nafPoints.wnd;17443 -1 wnd[i] = nafPoints.points;17444 -1 }17445 -117446 -1 // Comb small window NAFs17447 -1 for (i = len - 1; i >= 1; i -= 2) {17448 -1 var a = i - 1;17449 -1 var b = i;17450 -1 if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {17451 -1 naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength);17452 -1 naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength);17453 -1 max = Math.max(naf[a].length, max);17454 -1 max = Math.max(naf[b].length, max);17455 -1 continue;17456 -1 }17457 -117458 -1 var comb = [17459 -1 points[a], /* 1 */17460 -1 null, /* 3 */17461 -1 null, /* 5 */17462 -1 points[b], /* 7 */17463 -1 ];17464 -117465 -1 // Try to avoid Projective points, if possible17466 -1 if (points[a].y.cmp(points[b].y) === 0) {17467 -1 comb[1] = points[a].add(points[b]);17468 -1 comb[2] = points[a].toJ().mixedAdd(points[b].neg());17469 -1 } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {17470 -1 comb[1] = points[a].toJ().mixedAdd(points[b]);17471 -1 comb[2] = points[a].add(points[b].neg());17472 -1 } else {17473 -1 comb[1] = points[a].toJ().mixedAdd(points[b]);17474 -1 comb[2] = points[a].toJ().mixedAdd(points[b].neg());17475 -1 }17476 -117477 -1 var index = [17478 -1 -3, /* -1 -1 */17479 -1 -1, /* -1 0 */17480 -1 -5, /* -1 1 */17481 -1 -7, /* 0 -1 */17482 -1 0, /* 0 0 */17483 -1 7, /* 0 1 */17484 -1 5, /* 1 -1 */17485 -1 1, /* 1 0 */17486 -1 3, /* 1 1 */17487 -1 ];17488 -117489 -1 var jsf = getJSF(coeffs[a], coeffs[b]);17490 -1 max = Math.max(jsf[0].length, max);17491 -1 naf[a] = new Array(max);17492 -1 naf[b] = new Array(max);17493 -1 for (j = 0; j < max; j++) {17494 -1 var ja = jsf[0][j] | 0;17495 -1 var jb = jsf[1][j] | 0;17496 -117497 -1 naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];17498 -1 naf[b][j] = 0;17499 -1 wnd[a] = comb;17500 -1 }17501 -1 }17502 -117503 -1 var acc = this.jpoint(null, null, null);17504 -1 var tmp = this._wnafT4;17505 -1 for (i = max; i >= 0; i--) {17506 -1 var k = 0;17507 -117508 -1 while (i >= 0) {17509 -1 var zero = true;17510 -1 for (j = 0; j < len; j++) {17511 -1 tmp[j] = naf[j][i] | 0;17512 -1 if (tmp[j] !== 0)17513 -1 zero = false;17514 -1 }17515 -1 if (!zero)17516 -1 break;17517 -1 k++;17518 -1 i--;17519 -1 }17520 -1 if (i >= 0)17521 -1 k++;17522 -1 acc = acc.dblp(k);17523 -1 if (i < 0)17524 -1 break;17525 -117526 -1 for (j = 0; j < len; j++) {17527 -1 var z = tmp[j];17528 -1 p;17529 -1 if (z === 0)17530 -1 continue;17531 -1 else if (z > 0)17532 -1 p = wnd[j][(z - 1) >> 1];17533 -1 else if (z < 0)17534 -1 p = wnd[j][(-z - 1) >> 1].neg();17535 -117536 -1 if (p.type === 'affine')17537 -1 acc = acc.mixedAdd(p);17538 -1 else17539 -1 acc = acc.add(p);17540 -1 }17541 -1 }17542 -1 // Zeroify references17543 -1 for (i = 0; i < len; i++)17544 -1 wnd[i] = null;17545 -117546 -1 if (jacobianResult)17547 -1 return acc;17548 -1 else17549 -1 return acc.toP();17550 -1 };17551 -117552 -1 function BasePoint(curve, type) {17553 -1 this.curve = curve;17554 -1 this.type = type;17555 -1 this.precomputed = null;17556 -1 }17557 -1 BaseCurve.BasePoint = BasePoint;17558 -117559 -1 BasePoint.prototype.eq = function eq(/*other*/) {17560 -1 throw new Error('Not implemented');17561 -1 };17562 -117563 -1 BasePoint.prototype.validate = function validate() {17564 -1 return this.curve.validate(this);17565 -1 };17566 -117567 -1 BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {17568 -1 bytes = utils.toArray(bytes, enc);17569 -117570 -1 var len = this.p.byteLength();17571 -117572 -1 // uncompressed, hybrid-odd, hybrid-even17573 -1 if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&17574 -1 bytes.length - 1 === 2 * len) {17575 -1 if (bytes[0] === 0x06)17576 -1 assert(bytes[bytes.length - 1] % 2 === 0);17577 -1 else if (bytes[0] === 0x07)17578 -1 assert(bytes[bytes.length - 1] % 2 === 1);17579 -117580 -1 var res = this.point(bytes.slice(1, 1 + len),17581 -1 bytes.slice(1 + len, 1 + 2 * len));17582 -117583 -1 return res;17584 -1 } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&17585 -1 bytes.length - 1 === len) {17586 -1 return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);17587 -1 }17588 -1 throw new Error('Unknown point format');17589 -1 };17590 -117591 -1 BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {17592 -1 return this.encode(enc, true);17593 -1 };17594 -117595 -1 BasePoint.prototype._encode = function _encode(compact) {17596 -1 var len = this.curve.p.byteLength();17597 -1 var x = this.getX().toArray('be', len);17598 -117599 -1 if (compact)17600 -1 return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);17601 -117602 -1 return [ 0x04 ].concat(x, this.getY().toArray('be', len));17603 -1 };17604 -117605 -1 BasePoint.prototype.encode = function encode(enc, compact) {17606 -1 return utils.encode(this._encode(compact), enc);17607 -1 };17608 -117609 -1 BasePoint.prototype.precompute = function precompute(power) {17610 -1 if (this.precomputed)17611 -1 return this;17612 -117613 -1 var precomputed = {17614 -1 doubles: null,17615 -1 naf: null,17616 -1 beta: null,17617 -1 };17618 -1 precomputed.naf = this._getNAFPoints(8);17619 -1 precomputed.doubles = this._getDoubles(4, power);17620 -1 precomputed.beta = this._getBeta();17621 -1 this.precomputed = precomputed;17622 -117623 -1 return this;17624 -1 };17625 -117626 -1 BasePoint.prototype._hasDoubles = function _hasDoubles(k) {17627 -1 if (!this.precomputed)17628 -1 return false;17629 -117630 -1 var doubles = this.precomputed.doubles;17631 -1 if (!doubles)17632 -1 return false;17633 -117634 -1 return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);17635 -1 };17636 -117637 -1 BasePoint.prototype._getDoubles = function _getDoubles(step, power) {17638 -1 if (this.precomputed && this.precomputed.doubles)17639 -1 return this.precomputed.doubles;17640 -117641 -1 var doubles = [ this ];17642 -1 var acc = this;17643 -1 for (var i = 0; i < power; i += step) {17644 -1 for (var j = 0; j < step; j++)17645 -1 acc = acc.dbl();17646 -1 doubles.push(acc);17647 -1 }17648 -1 return {17649 -1 step: step,17650 -1 points: doubles,17651 -1 };17652 -1 };17653 -117654 -1 BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {17655 -1 if (this.precomputed && this.precomputed.naf)17656 -1 return this.precomputed.naf;17657 -117658 -1 var res = [ this ];17659 -1 var max = (1 << wnd) - 1;17660 -1 var dbl = max === 1 ? null : this.dbl();17661 -1 for (var i = 1; i < max; i++)17662 -1 res[i] = res[i - 1].add(dbl);17663 -1 return {17664 -1 wnd: wnd,17665 -1 points: res,17666 -1 };17667 -1 };17668 -117669 -1 BasePoint.prototype._getBeta = function _getBeta() {17670 -1 return null;17671 -1 };17672 -117673 -1 BasePoint.prototype.dblp = function dblp(k) {17674 -1 var r = this;17675 -1 for (var i = 0; i < k; i++)17676 -1 r = r.dbl();17677 -1 return r;17678 -1 };17679 -117680 -1 },{"../utils":97,"bn.js":98}],85:[function(require,module,exports){17681 -1 'use strict';17682 -117683 -1 var utils = require('../utils');17684 -1 var BN = require('bn.js');17685 -1 var inherits = require('inherits');17686 -1 var Base = require('./base');17687 -117688 -1 var assert = utils.assert;17689 -117690 -1 function EdwardsCurve(conf) {17691 -1 // NOTE: Important as we are creating point in Base.call()17692 -1 this.twisted = (conf.a | 0) !== 1;17693 -1 this.mOneA = this.twisted && (conf.a | 0) === -1;17694 -1 this.extended = this.mOneA;17695 -117696 -1 Base.call(this, 'edwards', conf);17697 -117698 -1 this.a = new BN(conf.a, 16).umod(this.red.m);17699 -1 this.a = this.a.toRed(this.red);17700 -1 this.c = new BN(conf.c, 16).toRed(this.red);17701 -1 this.c2 = this.c.redSqr();17702 -1 this.d = new BN(conf.d, 16).toRed(this.red);17703 -1 this.dd = this.d.redAdd(this.d);17704 -117705 -1 assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);17706 -1 this.oneC = (conf.c | 0) === 1;17707 -1 }17708 -1 inherits(EdwardsCurve, Base);17709 -1 module.exports = EdwardsCurve;17710 -117711 -1 EdwardsCurve.prototype._mulA = function _mulA(num) {17712 -1 if (this.mOneA)17713 -1 return num.redNeg();17714 -1 else17715 -1 return this.a.redMul(num);17716 -1 };17717 -117718 -1 EdwardsCurve.prototype._mulC = function _mulC(num) {17719 -1 if (this.oneC)17720 -1 return num;17721 -1 else17722 -1 return this.c.redMul(num);17723 -1 };17724 -117725 -1 // Just for compatibility with Short curve17726 -1 EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {17727 -1 return this.point(x, y, z, t);17728 -1 };17729 -117730 -1 EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {17731 -1 x = new BN(x, 16);17732 -1 if (!x.red)17733 -1 x = x.toRed(this.red);17734 -117735 -1 var x2 = x.redSqr();17736 -1 var rhs = this.c2.redSub(this.a.redMul(x2));17737 -1 var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));17738 -117739 -1 var y2 = rhs.redMul(lhs.redInvm());17740 -1 var y = y2.redSqrt();17741 -1 if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)17742 -1 throw new Error('invalid point');17743 -117744 -1 var isOdd = y.fromRed().isOdd();17745 -1 if (odd && !isOdd || !odd && isOdd)17746 -1 y = y.redNeg();17747 -117748 -1 return this.point(x, y);17749 -1 };17750 -117751 -1 EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {17752 -1 y = new BN(y, 16);17753 -1 if (!y.red)17754 -1 y = y.toRed(this.red);17755 -117756 -1 // x^2 = (y^2 - c^2) / (c^2 d y^2 - a)17757 -1 var y2 = y.redSqr();17758 -1 var lhs = y2.redSub(this.c2);17759 -1 var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);17760 -1 var x2 = lhs.redMul(rhs.redInvm());17761 -117762 -1 if (x2.cmp(this.zero) === 0) {17763 -1 if (odd)17764 -1 throw new Error('invalid point');17765 -1 else17766 -1 return this.point(this.zero, y);17767 -1 }17768 -117769 -1 var x = x2.redSqrt();17770 -1 if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)17771 -1 throw new Error('invalid point');17772 -117773 -1 if (x.fromRed().isOdd() !== odd)17774 -1 x = x.redNeg();17775 -117776 -1 return this.point(x, y);17777 -1 };17778 -117779 -1 EdwardsCurve.prototype.validate = function validate(point) {17780 -1 if (point.isInfinity())17781 -1 return true;17782 -117783 -1 // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)17784 -1 point.normalize();17785 -117786 -1 var x2 = point.x.redSqr();17787 -1 var y2 = point.y.redSqr();17788 -1 var lhs = x2.redMul(this.a).redAdd(y2);17789 -1 var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));17790 -117791 -1 return lhs.cmp(rhs) === 0;17792 -1 };17793 -117794 -1 function Point(curve, x, y, z, t) {17795 -1 Base.BasePoint.call(this, curve, 'projective');17796 -1 if (x === null && y === null && z === null) {17797 -1 this.x = this.curve.zero;17798 -1 this.y = this.curve.one;17799 -1 this.z = this.curve.one;17800 -1 this.t = this.curve.zero;17801 -1 this.zOne = true;17802 -1 } else {17803 -1 this.x = new BN(x, 16);17804 -1 this.y = new BN(y, 16);17805 -1 this.z = z ? new BN(z, 16) : this.curve.one;17806 -1 this.t = t && new BN(t, 16);17807 -1 if (!this.x.red)17808 -1 this.x = this.x.toRed(this.curve.red);17809 -1 if (!this.y.red)17810 -1 this.y = this.y.toRed(this.curve.red);17811 -1 if (!this.z.red)17812 -1 this.z = this.z.toRed(this.curve.red);17813 -1 if (this.t && !this.t.red)17814 -1 this.t = this.t.toRed(this.curve.red);17815 -1 this.zOne = this.z === this.curve.one;17816 -117817 -1 // Use extended coordinates17818 -1 if (this.curve.extended && !this.t) {17819 -1 this.t = this.x.redMul(this.y);17820 -1 if (!this.zOne)17821 -1 this.t = this.t.redMul(this.z.redInvm());17822 -1 }17823 -1 }17824 -1 }17825 -1 inherits(Point, Base.BasePoint);17826 -117827 -1 EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {17828 -1 return Point.fromJSON(this, obj);17829 -1 };17830 -117831 -1 EdwardsCurve.prototype.point = function point(x, y, z, t) {17832 -1 return new Point(this, x, y, z, t);17833 -1 };17834 -117835 -1 Point.fromJSON = function fromJSON(curve, obj) {17836 -1 return new Point(curve, obj[0], obj[1], obj[2]);17837 -1 };17838 -117839 -1 Point.prototype.inspect = function inspect() {17840 -1 if (this.isInfinity())17841 -1 return '<EC Point Infinity>';17842 -1 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +17843 -1 ' y: ' + this.y.fromRed().toString(16, 2) +17844 -1 ' z: ' + this.z.fromRed().toString(16, 2) + '>';17845 -1 };17846 -117847 -1 Point.prototype.isInfinity = function isInfinity() {17848 -1 // XXX This code assumes that zero is always zero in red17849 -1 return this.x.cmpn(0) === 0 &&17850 -1 (this.y.cmp(this.z) === 0 ||17851 -1 (this.zOne && this.y.cmp(this.curve.c) === 0));17852 -1 };17853 -117854 -1 Point.prototype._extDbl = function _extDbl() {17855 -1 // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html17856 -1 // #doubling-dbl-2008-hwcd17857 -1 // 4M + 4S17858 -117859 -1 // A = X1^217860 -1 var a = this.x.redSqr();17861 -1 // B = Y1^217862 -1 var b = this.y.redSqr();17863 -1 // C = 2 * Z1^217864 -1 var c = this.z.redSqr();17865 -1 c = c.redIAdd(c);17866 -1 // D = a * A17867 -1 var d = this.curve._mulA(a);17868 -1 // E = (X1 + Y1)^2 - A - B17869 -1 var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);17870 -1 // G = D + B17871 -1 var g = d.redAdd(b);17872 -1 // F = G - C17873 -1 var f = g.redSub(c);17874 -1 // H = D - B17875 -1 var h = d.redSub(b);17876 -1 // X3 = E * F17877 -1 var nx = e.redMul(f);17878 -1 // Y3 = G * H17879 -1 var ny = g.redMul(h);17880 -1 // T3 = E * H17881 -1 var nt = e.redMul(h);17882 -1 // Z3 = F * G17883 -1 var nz = f.redMul(g);17884 -1 return this.curve.point(nx, ny, nz, nt);17885 -1 };17886 -117887 -1 Point.prototype._projDbl = function _projDbl() {17888 -1 // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html17889 -1 // #doubling-dbl-2008-bbjlp17890 -1 // #doubling-dbl-2007-bl17891 -1 // and others17892 -1 // Generally 3M + 4S or 2M + 4S17893 -117894 -1 // B = (X1 + Y1)^217895 -1 var b = this.x.redAdd(this.y).redSqr();17896 -1 // C = X1^217897 -1 var c = this.x.redSqr();17898 -1 // D = Y1^217899 -1 var d = this.y.redSqr();17900 -117901 -1 var nx;17902 -1 var ny;17903 -1 var nz;17904 -1 var e;17905 -1 var h;17906 -1 var j;17907 -1 if (this.curve.twisted) {17908 -1 // E = a * C17909 -1 e = this.curve._mulA(c);17910 -1 // F = E + D17911 -1 var f = e.redAdd(d);17912 -1 if (this.zOne) {17913 -1 // X3 = (B - C - D) * (F - 2)17914 -1 nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));17915 -1 // Y3 = F * (E - D)17916 -1 ny = f.redMul(e.redSub(d));17917 -1 // Z3 = F^2 - 2 * F17918 -1 nz = f.redSqr().redSub(f).redSub(f);17919 -1 } else {17920 -1 // H = Z1^217921 -1 h = this.z.redSqr();17922 -1 // J = F - 2 * H17923 -1 j = f.redSub(h).redISub(h);17924 -1 // X3 = (B-C-D)*J17925 -1 nx = b.redSub(c).redISub(d).redMul(j);17926 -1 // Y3 = F * (E - D)17927 -1 ny = f.redMul(e.redSub(d));17928 -1 // Z3 = F * J17929 -1 nz = f.redMul(j);17930 -1 }17931 -1 } else {17932 -1 // E = C + D17933 -1 e = c.redAdd(d);17934 -1 // H = (c * Z1)^217935 -1 h = this.curve._mulC(this.z).redSqr();17936 -1 // J = E - 2 * H17937 -1 j = e.redSub(h).redSub(h);17938 -1 // X3 = c * (B - E) * J17939 -1 nx = this.curve._mulC(b.redISub(e)).redMul(j);17940 -1 // Y3 = c * E * (C - D)17941 -1 ny = this.curve._mulC(e).redMul(c.redISub(d));17942 -1 // Z3 = E * J17943 -1 nz = e.redMul(j);17944 -1 }17945 -1 return this.curve.point(nx, ny, nz);17946 -1 };17947 -117948 -1 Point.prototype.dbl = function dbl() {17949 -1 if (this.isInfinity())17950 -1 return this;17951 -117952 -1 // Double in extended coordinates17953 -1 if (this.curve.extended)17954 -1 return this._extDbl();17955 -1 else17956 -1 return this._projDbl();17957 -1 };17958 -117959 -1 Point.prototype._extAdd = function _extAdd(p) {17960 -1 // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html17961 -1 // #addition-add-2008-hwcd-317962 -1 // 8M17963 -117964 -1 // A = (Y1 - X1) * (Y2 - X2)17965 -1 var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));17966 -1 // B = (Y1 + X1) * (Y2 + X2)17967 -1 var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));17968 -1 // C = T1 * k * T217969 -1 var c = this.t.redMul(this.curve.dd).redMul(p.t);17970 -1 // D = Z1 * 2 * Z217971 -1 var d = this.z.redMul(p.z.redAdd(p.z));17972 -1 // E = B - A17973 -1 var e = b.redSub(a);17974 -1 // F = D - C17975 -1 var f = d.redSub(c);17976 -1 // G = D + C17977 -1 var g = d.redAdd(c);17978 -1 // H = B + A17979 -1 var h = b.redAdd(a);17980 -1 // X3 = E * F17981 -1 var nx = e.redMul(f);17982 -1 // Y3 = G * H17983 -1 var ny = g.redMul(h);17984 -1 // T3 = E * H17985 -1 var nt = e.redMul(h);17986 -1 // Z3 = F * G17987 -1 var nz = f.redMul(g);17988 -1 return this.curve.point(nx, ny, nz, nt);17989 -1 };17990 -117991 -1 Point.prototype._projAdd = function _projAdd(p) {17992 -1 // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html17993 -1 // #addition-add-2008-bbjlp17994 -1 // #addition-add-2007-bl17995 -1 // 10M + 1S17996 -117997 -1 // A = Z1 * Z217998 -1 var a = this.z.redMul(p.z);17999 -1 // B = A^218000 -1 var b = a.redSqr();18001 -1 // C = X1 * X218002 -1 var c = this.x.redMul(p.x);18003 -1 // D = Y1 * Y218004 -1 var d = this.y.redMul(p.y);18005 -1 // E = d * C * D18006 -1 var e = this.curve.d.redMul(c).redMul(d);18007 -1 // F = B - E18008 -1 var f = b.redSub(e);18009 -1 // G = B + E18010 -1 var g = b.redAdd(e);18011 -1 // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)18012 -1 var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);18013 -1 var nx = a.redMul(f).redMul(tmp);18014 -1 var ny;18015 -1 var nz;18016 -1 if (this.curve.twisted) {18017 -1 // Y3 = A * G * (D - a * C)18018 -1 ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));18019 -1 // Z3 = F * G18020 -1 nz = f.redMul(g);18021 -1 } else {18022 -1 // Y3 = A * G * (D - C)18023 -1 ny = a.redMul(g).redMul(d.redSub(c));18024 -1 // Z3 = c * F * G18025 -1 nz = this.curve._mulC(f).redMul(g);18026 -1 }18027 -1 return this.curve.point(nx, ny, nz);18028 -1 };18029 -118030 -1 Point.prototype.add = function add(p) {18031 -1 if (this.isInfinity())18032 -1 return p;18033 -1 if (p.isInfinity())18034 -1 return this;18035 -118036 -1 if (this.curve.extended)18037 -1 return this._extAdd(p);18038 -1 else18039 -1 return this._projAdd(p);18040 -1 };18041 -118042 -1 Point.prototype.mul = function mul(k) {18043 -1 if (this._hasDoubles(k))18044 -1 return this.curve._fixedNafMul(this, k);18045 -1 else18046 -1 return this.curve._wnafMul(this, k);18047 -1 };18048 -118049 -1 Point.prototype.mulAdd = function mulAdd(k1, p, k2) {18050 -1 return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);18051 -1 };18052 -118053 -1 Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {18054 -1 return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);18055 -1 };18056 -118057 -1 Point.prototype.normalize = function normalize() {18058 -1 if (this.zOne)18059 -1 return this;18060 -118061 -1 // Normalize coordinates18062 -1 var zi = this.z.redInvm();18063 -1 this.x = this.x.redMul(zi);18064 -1 this.y = this.y.redMul(zi);18065 -1 if (this.t)18066 -1 this.t = this.t.redMul(zi);18067 -1 this.z = this.curve.one;18068 -1 this.zOne = true;18069 -1 return this;18070 -1 };18071 -118072 -1 Point.prototype.neg = function neg() {18073 -1 return this.curve.point(this.x.redNeg(),18074 -1 this.y,18075 -1 this.z,18076 -1 this.t && this.t.redNeg());18077 -1 };18078 -118079 -1 Point.prototype.getX = function getX() {18080 -1 this.normalize();18081 -1 return this.x.fromRed();18082 -1 };18083 -118084 -1 Point.prototype.getY = function getY() {18085 -1 this.normalize();18086 -1 return this.y.fromRed();18087 -1 };18088 -118089 -1 Point.prototype.eq = function eq(other) {18090 -1 return this === other ||18091 -1 this.getX().cmp(other.getX()) === 0 &&18092 -1 this.getY().cmp(other.getY()) === 0;18093 -1 };18094 -118095 -1 Point.prototype.eqXToP = function eqXToP(x) {18096 -1 var rx = x.toRed(this.curve.red).redMul(this.z);18097 -1 if (this.x.cmp(rx) === 0)18098 -1 return true;18099 -118100 -1 var xc = x.clone();18101 -1 var t = this.curve.redN.redMul(this.z);18102 -1 for (;;) {18103 -1 xc.iadd(this.curve.n);18104 -1 if (xc.cmp(this.curve.p) >= 0)18105 -1 return false;18106 -118107 -1 rx.redIAdd(t);18108 -1 if (this.x.cmp(rx) === 0)18109 -1 return true;18110 -1 }18111 -1 };18112 -118113 -1 // Compatibility with BaseCurve18114 -1 Point.prototype.toP = Point.prototype.normalize;18115 -1 Point.prototype.mixedAdd = Point.prototype.add;18116 -118117 -1 },{"../utils":97,"./base":84,"bn.js":98,"inherits":132}],86:[function(require,module,exports){18118 -1 'use strict';18119 -118120 -1 var curve = exports;18121 -118122 -1 curve.base = require('./base');18123 -1 curve.short = require('./short');18124 -1 curve.mont = require('./mont');18125 -1 curve.edwards = require('./edwards');18126 -118127 -1 },{"./base":84,"./edwards":85,"./mont":87,"./short":88}],87:[function(require,module,exports){18128 -1 'use strict';18129 -118130 -1 var BN = require('bn.js');18131 -1 var inherits = require('inherits');18132 -1 var Base = require('./base');18133 -118134 -1 var utils = require('../utils');18135 -118136 -1 function MontCurve(conf) {18137 -1 Base.call(this, 'mont', conf);18138 -118139 -1 this.a = new BN(conf.a, 16).toRed(this.red);18140 -1 this.b = new BN(conf.b, 16).toRed(this.red);18141 -1 this.i4 = new BN(4).toRed(this.red).redInvm();18142 -1 this.two = new BN(2).toRed(this.red);18143 -1 this.a24 = this.i4.redMul(this.a.redAdd(this.two));18144 -1 }18145 -1 inherits(MontCurve, Base);18146 -1 module.exports = MontCurve;18147 -118148 -1 MontCurve.prototype.validate = function validate(point) {18149 -1 var x = point.normalize().x;18150 -1 var x2 = x.redSqr();18151 -1 var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);18152 -1 var y = rhs.redSqrt();18153 -118154 -1 return y.redSqr().cmp(rhs) === 0;18155 -1 };18156 -118157 -1 function Point(curve, x, z) {18158 -1 Base.BasePoint.call(this, curve, 'projective');18159 -1 if (x === null && z === null) {18160 -1 this.x = this.curve.one;18161 -1 this.z = this.curve.zero;18162 -1 } else {18163 -1 this.x = new BN(x, 16);18164 -1 this.z = new BN(z, 16);18165 -1 if (!this.x.red)18166 -1 this.x = this.x.toRed(this.curve.red);18167 -1 if (!this.z.red)18168 -1 this.z = this.z.toRed(this.curve.red);18169 -1 }18170 -1 }18171 -1 inherits(Point, Base.BasePoint);18172 -118173 -1 MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {18174 -1 return this.point(utils.toArray(bytes, enc), 1);18175 -1 };18176 -118177 -1 MontCurve.prototype.point = function point(x, z) {18178 -1 return new Point(this, x, z);18179 -1 };18180 -118181 -1 MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {18182 -1 return Point.fromJSON(this, obj);18183 -1 };18184 -118185 -1 Point.prototype.precompute = function precompute() {18186 -1 // No-op18187 -1 };18188 -118189 -1 Point.prototype._encode = function _encode() {18190 -1 return this.getX().toArray('be', this.curve.p.byteLength());18191 -1 };18192 -118193 -1 Point.fromJSON = function fromJSON(curve, obj) {18194 -1 return new Point(curve, obj[0], obj[1] || curve.one);18195 -1 };18196 -118197 -1 Point.prototype.inspect = function inspect() {18198 -1 if (this.isInfinity())18199 -1 return '<EC Point Infinity>';18200 -1 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +18201 -1 ' z: ' + this.z.fromRed().toString(16, 2) + '>';18202 -1 };18203 -118204 -1 Point.prototype.isInfinity = function isInfinity() {18205 -1 // XXX This code assumes that zero is always zero in red18206 -1 return this.z.cmpn(0) === 0;18207 -1 };18208 -118209 -1 Point.prototype.dbl = function dbl() {18210 -1 // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-318211 -1 // 2M + 2S + 4A18212 -118213 -1 // A = X1 + Z118214 -1 var a = this.x.redAdd(this.z);18215 -1 // AA = A^218216 -1 var aa = a.redSqr();18217 -1 // B = X1 - Z118218 -1 var b = this.x.redSub(this.z);18219 -1 // BB = B^218220 -1 var bb = b.redSqr();18221 -1 // C = AA - BB18222 -1 var c = aa.redSub(bb);18223 -1 // X3 = AA * BB18224 -1 var nx = aa.redMul(bb);18225 -1 // Z3 = C * (BB + A24 * C)18226 -1 var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));18227 -1 return this.curve.point(nx, nz);18228 -1 };18229 -118230 -1 Point.prototype.add = function add() {18231 -1 throw new Error('Not supported on Montgomery curve');18232 -1 };18233 -118234 -1 Point.prototype.diffAdd = function diffAdd(p, diff) {18235 -1 // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-318236 -1 // 4M + 2S + 6A18237 -118238 -1 // A = X2 + Z218239 -1 var a = this.x.redAdd(this.z);18240 -1 // B = X2 - Z218241 -1 var b = this.x.redSub(this.z);18242 -1 // C = X3 + Z318243 -1 var c = p.x.redAdd(p.z);18244 -1 // D = X3 - Z318245 -1 var d = p.x.redSub(p.z);18246 -1 // DA = D * A18247 -1 var da = d.redMul(a);18248 -1 // CB = C * B18249 -1 var cb = c.redMul(b);18250 -1 // X5 = Z1 * (DA + CB)^218251 -1 var nx = diff.z.redMul(da.redAdd(cb).redSqr());18252 -1 // Z5 = X1 * (DA - CB)^218253 -1 var nz = diff.x.redMul(da.redISub(cb).redSqr());18254 -1 return this.curve.point(nx, nz);18255 -1 };18256 -118257 -1 Point.prototype.mul = function mul(k) {18258 -1 var t = k.clone();18259 -1 var a = this; // (N / 2) * Q + Q18260 -1 var b = this.curve.point(null, null); // (N / 2) * Q18261 -1 var c = this; // Q18262 -118263 -1 for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))18264 -1 bits.push(t.andln(1));18265 -118266 -1 for (var i = bits.length - 1; i >= 0; i--) {18267 -1 if (bits[i] === 0) {18268 -1 // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q18269 -1 a = a.diffAdd(b, c);18270 -1 // N * Q = 2 * ((N / 2) * Q + Q))18271 -1 b = b.dbl();18272 -1 } else {18273 -1 // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)18274 -1 b = a.diffAdd(b, c);18275 -1 // N * Q + Q = 2 * ((N / 2) * Q + Q)18276 -1 a = a.dbl();18277 -1 }18278 -1 }18279 -1 return b;18280 -1 };18281 -118282 -1 Point.prototype.mulAdd = function mulAdd() {18283 -1 throw new Error('Not supported on Montgomery curve');18284 -1 };18285 -118286 -1 Point.prototype.jumlAdd = function jumlAdd() {18287 -1 throw new Error('Not supported on Montgomery curve');18288 -1 };18289 -118290 -1 Point.prototype.eq = function eq(other) {18291 -1 return this.getX().cmp(other.getX()) === 0;18292 -1 };18293 -118294 -1 Point.prototype.normalize = function normalize() {18295 -1 this.x = this.x.redMul(this.z.redInvm());18296 -1 this.z = this.curve.one;18297 -1 return this;18298 -1 };18299 -118300 -1 Point.prototype.getX = function getX() {18301 -1 // Normalize coordinates18302 -1 this.normalize();18303 -118304 -1 return this.x.fromRed();18305 -1 };18306 -118307 -1 },{"../utils":97,"./base":84,"bn.js":98,"inherits":132}],88:[function(require,module,exports){18308 -1 'use strict';18309 -118310 -1 var utils = require('../utils');18311 -1 var BN = require('bn.js');18312 -1 var inherits = require('inherits');18313 -1 var Base = require('./base');18314 -118315 -1 var assert = utils.assert;18316 -118317 -1 function ShortCurve(conf) {18318 -1 Base.call(this, 'short', conf);18319 -118320 -1 this.a = new BN(conf.a, 16).toRed(this.red);18321 -1 this.b = new BN(conf.b, 16).toRed(this.red);18322 -1 this.tinv = this.two.redInvm();18323 -118324 -1 this.zeroA = this.a.fromRed().cmpn(0) === 0;18325 -1 this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;18326 -118327 -1 // If the curve is endomorphic, precalculate beta and lambda18328 -1 this.endo = this._getEndomorphism(conf);18329 -1 this._endoWnafT1 = new Array(4);18330 -1 this._endoWnafT2 = new Array(4);18331 -1 }18332 -1 inherits(ShortCurve, Base);18333 -1 module.exports = ShortCurve;18334 -118335 -1 ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {18336 -1 // No efficient endomorphism18337 -1 if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)18338 -1 return;18339 -118340 -1 // Compute beta and lambda, that lambda * P = (beta * Px; Py)18341 -1 var beta;18342 -1 var lambda;18343 -1 if (conf.beta) {18344 -1 beta = new BN(conf.beta, 16).toRed(this.red);18345 -1 } else {18346 -1 var betas = this._getEndoRoots(this.p);18347 -1 // Choose the smallest beta18348 -1 beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];18349 -1 beta = beta.toRed(this.red);18350 -1 }18351 -1 if (conf.lambda) {18352 -1 lambda = new BN(conf.lambda, 16);18353 -1 } else {18354 -1 // Choose the lambda that is matching selected beta18355 -1 var lambdas = this._getEndoRoots(this.n);18356 -1 if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {18357 -1 lambda = lambdas[0];18358 -1 } else {18359 -1 lambda = lambdas[1];18360 -1 assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);18361 -1 }18362 -1 }18363 -118364 -1 // Get basis vectors, used for balanced length-two representation18365 -1 var basis;18366 -1 if (conf.basis) {18367 -1 basis = conf.basis.map(function(vec) {18368 -1 return {18369 -1 a: new BN(vec.a, 16),18370 -1 b: new BN(vec.b, 16),18371 -1 };18372 -1 });18373 -1 } else {18374 -1 basis = this._getEndoBasis(lambda);18375 -1 }18376 -118377 -1 return {18378 -1 beta: beta,18379 -1 lambda: lambda,18380 -1 basis: basis,18381 -1 };18382 -1 };18383 -118384 -1 ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {18385 -1 // Find roots of for x^2 + x + 1 in F18386 -1 // Root = (-1 +- Sqrt(-3)) / 218387 -1 //18388 -1 var red = num === this.p ? this.red : BN.mont(num);18389 -1 var tinv = new BN(2).toRed(red).redInvm();18390 -1 var ntinv = tinv.redNeg();18391 -118392 -1 var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);18393 -118394 -1 var l1 = ntinv.redAdd(s).fromRed();18395 -1 var l2 = ntinv.redSub(s).fromRed();18396 -1 return [ l1, l2 ];18397 -1 };18398 -118399 -1 ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {18400 -1 // aprxSqrt >= sqrt(this.n)18401 -1 var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));18402 -118403 -1 // 3.7418404 -1 // Run EGCD, until r(L + 1) < aprxSqrt18405 -1 var u = lambda;18406 -1 var v = this.n.clone();18407 -1 var x1 = new BN(1);18408 -1 var y1 = new BN(0);18409 -1 var x2 = new BN(0);18410 -1 var y2 = new BN(1);18411 -118412 -1 // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)18413 -1 var a0;18414 -1 var b0;18415 -1 // First vector18416 -1 var a1;18417 -1 var b1;18418 -1 // Second vector18419 -1 var a2;18420 -1 var b2;18421 -118422 -1 var prevR;18423 -1 var i = 0;18424 -1 var r;18425 -1 var x;18426 -1 while (u.cmpn(0) !== 0) {18427 -1 var q = v.div(u);18428 -1 r = v.sub(q.mul(u));18429 -1 x = x2.sub(q.mul(x1));18430 -1 var y = y2.sub(q.mul(y1));18431 -118432 -1 if (!a1 && r.cmp(aprxSqrt) < 0) {18433 -1 a0 = prevR.neg();18434 -1 b0 = x1;18435 -1 a1 = r.neg();18436 -1 b1 = x;18437 -1 } else if (a1 && ++i === 2) {18438 -1 break;18439 -1 }18440 -1 prevR = r;18441 -118442 -1 v = u;18443 -1 u = r;18444 -1 x2 = x1;18445 -1 x1 = x;18446 -1 y2 = y1;18447 -1 y1 = y;18448 -1 }18449 -1 a2 = r.neg();18450 -1 b2 = x;18451 -118452 -1 var len1 = a1.sqr().add(b1.sqr());18453 -1 var len2 = a2.sqr().add(b2.sqr());18454 -1 if (len2.cmp(len1) >= 0) {18455 -1 a2 = a0;18456 -1 b2 = b0;18457 -1 }18458 -118459 -1 // Normalize signs18460 -1 if (a1.negative) {18461 -1 a1 = a1.neg();18462 -1 b1 = b1.neg();18463 -1 }18464 -1 if (a2.negative) {18465 -1 a2 = a2.neg();18466 -1 b2 = b2.neg();18467 -1 }18468 -118469 -1 return [18470 -1 { a: a1, b: b1 },18471 -1 { a: a2, b: b2 },18472 -1 ];18473 -1 };18474 -118475 -1 ShortCurve.prototype._endoSplit = function _endoSplit(k) {18476 -1 var basis = this.endo.basis;18477 -1 var v1 = basis[0];18478 -1 var v2 = basis[1];18479 -118480 -1 var c1 = v2.b.mul(k).divRound(this.n);18481 -1 var c2 = v1.b.neg().mul(k).divRound(this.n);18482 -118483 -1 var p1 = c1.mul(v1.a);18484 -1 var p2 = c2.mul(v2.a);18485 -1 var q1 = c1.mul(v1.b);18486 -1 var q2 = c2.mul(v2.b);18487 -118488 -1 // Calculate answer18489 -1 var k1 = k.sub(p1).sub(p2);18490 -1 var k2 = q1.add(q2).neg();18491 -1 return { k1: k1, k2: k2 };18492 -1 };18493 -118494 -1 ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {18495 -1 x = new BN(x, 16);18496 -1 if (!x.red)18497 -1 x = x.toRed(this.red);18498 -118499 -1 var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);18500 -1 var y = y2.redSqrt();18501 -1 if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)18502 -1 throw new Error('invalid point');18503 -118504 -1 // XXX Is there any way to tell if the number is odd without converting it18505 -1 // to non-red form?18506 -1 var isOdd = y.fromRed().isOdd();18507 -1 if (odd && !isOdd || !odd && isOdd)18508 -1 y = y.redNeg();18509 -118510 -1 return this.point(x, y);18511 -1 };18512 -118513 -1 ShortCurve.prototype.validate = function validate(point) {18514 -1 if (point.inf)18515 -1 return true;18516 -118517 -1 var x = point.x;18518 -1 var y = point.y;18519 -118520 -1 var ax = this.a.redMul(x);18521 -1 var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);18522 -1 return y.redSqr().redISub(rhs).cmpn(0) === 0;18523 -1 };18524 -118525 -1 ShortCurve.prototype._endoWnafMulAdd =18526 -1 function _endoWnafMulAdd(points, coeffs, jacobianResult) {18527 -1 var npoints = this._endoWnafT1;18528 -1 var ncoeffs = this._endoWnafT2;18529 -1 for (var i = 0; i < points.length; i++) {18530 -1 var split = this._endoSplit(coeffs[i]);18531 -1 var p = points[i];18532 -1 var beta = p._getBeta();18533 -118534 -1 if (split.k1.negative) {18535 -1 split.k1.ineg();18536 -1 p = p.neg(true);18537 -1 }18538 -1 if (split.k2.negative) {18539 -1 split.k2.ineg();18540 -1 beta = beta.neg(true);18541 -1 }18542 -118543 -1 npoints[i * 2] = p;18544 -1 npoints[i * 2 + 1] = beta;18545 -1 ncoeffs[i * 2] = split.k1;18546 -1 ncoeffs[i * 2 + 1] = split.k2;18547 -1 }18548 -1 var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);18549 -118550 -1 // Clean-up references to points and coefficients18551 -1 for (var j = 0; j < i * 2; j++) {18552 -1 npoints[j] = null;18553 -1 ncoeffs[j] = null;18554 -1 }18555 -1 return res;18556 -1 };18557 -118558 -1 function Point(curve, x, y, isRed) {18559 -1 Base.BasePoint.call(this, curve, 'affine');18560 -1 if (x === null && y === null) {18561 -1 this.x = null;18562 -1 this.y = null;18563 -1 this.inf = true;18564 -1 } else {18565 -1 this.x = new BN(x, 16);18566 -1 this.y = new BN(y, 16);18567 -1 // Force redgomery representation when loading from JSON18568 -1 if (isRed) {18569 -1 this.x.forceRed(this.curve.red);18570 -1 this.y.forceRed(this.curve.red);18571 -1 }18572 -1 if (!this.x.red)18573 -1 this.x = this.x.toRed(this.curve.red);18574 -1 if (!this.y.red)18575 -1 this.y = this.y.toRed(this.curve.red);18576 -1 this.inf = false;18577 -1 }18578 -1 }18579 -1 inherits(Point, Base.BasePoint);18580 -118581 -1 ShortCurve.prototype.point = function point(x, y, isRed) {18582 -1 return new Point(this, x, y, isRed);18583 -1 };18584 -118585 -1 ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {18586 -1 return Point.fromJSON(this, obj, red);18587 -1 };18588 -118589 -1 Point.prototype._getBeta = function _getBeta() {18590 -1 if (!this.curve.endo)18591 -1 return;18592 -118593 -1 var pre = this.precomputed;18594 -1 if (pre && pre.beta)18595 -1 return pre.beta;18596 -118597 -1 var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);18598 -1 if (pre) {18599 -1 var curve = this.curve;18600 -1 var endoMul = function(p) {18601 -1 return curve.point(p.x.redMul(curve.endo.beta), p.y);18602 -1 };18603 -1 pre.beta = beta;18604 -1 beta.precomputed = {18605 -1 beta: null,18606 -1 naf: pre.naf && {18607 -1 wnd: pre.naf.wnd,18608 -1 points: pre.naf.points.map(endoMul),18609 -1 },18610 -1 doubles: pre.doubles && {18611 -1 step: pre.doubles.step,18612 -1 points: pre.doubles.points.map(endoMul),18613 -1 },18614 -1 };18615 -1 }18616 -1 return beta;18617 -1 };18618 -118619 -1 Point.prototype.toJSON = function toJSON() {18620 -1 if (!this.precomputed)18621 -1 return [ this.x, this.y ];18622 -118623 -1 return [ this.x, this.y, this.precomputed && {18624 -1 doubles: this.precomputed.doubles && {18625 -1 step: this.precomputed.doubles.step,18626 -1 points: this.precomputed.doubles.points.slice(1),18627 -1 },18628 -1 naf: this.precomputed.naf && {18629 -1 wnd: this.precomputed.naf.wnd,18630 -1 points: this.precomputed.naf.points.slice(1),18631 -1 },18632 -1 } ];18633 -1 };18634 -118635 -1 Point.fromJSON = function fromJSON(curve, obj, red) {18636 -1 if (typeof obj === 'string')18637 -1 obj = JSON.parse(obj);18638 -1 var res = curve.point(obj[0], obj[1], red);18639 -1 if (!obj[2])18640 -1 return res;18641 -118642 -1 function obj2point(obj) {18643 -1 return curve.point(obj[0], obj[1], red);18644 -1 }18645 -118646 -1 var pre = obj[2];18647 -1 res.precomputed = {18648 -1 beta: null,18649 -1 doubles: pre.doubles && {18650 -1 step: pre.doubles.step,18651 -1 points: [ res ].concat(pre.doubles.points.map(obj2point)),18652 -1 },18653 -1 naf: pre.naf && {18654 -1 wnd: pre.naf.wnd,18655 -1 points: [ res ].concat(pre.naf.points.map(obj2point)),18656 -1 },18657 -1 };18658 -1 return res;18659 -1 };18660 -118661 -1 Point.prototype.inspect = function inspect() {18662 -1 if (this.isInfinity())18663 -1 return '<EC Point Infinity>';18664 -1 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +18665 -1 ' y: ' + this.y.fromRed().toString(16, 2) + '>';18666 -1 };18667 -118668 -1 Point.prototype.isInfinity = function isInfinity() {18669 -1 return this.inf;18670 -1 };18671 -118672 -1 Point.prototype.add = function add(p) {18673 -1 // O + P = P18674 -1 if (this.inf)18675 -1 return p;18676 -118677 -1 // P + O = P18678 -1 if (p.inf)18679 -1 return this;18680 -118681 -1 // P + P = 2P18682 -1 if (this.eq(p))18683 -1 return this.dbl();18684 -118685 -1 // P + (-P) = O18686 -1 if (this.neg().eq(p))18687 -1 return this.curve.point(null, null);18688 -118689 -1 // P + Q = O18690 -1 if (this.x.cmp(p.x) === 0)18691 -1 return this.curve.point(null, null);18692 -118693 -1 var c = this.y.redSub(p.y);18694 -1 if (c.cmpn(0) !== 0)18695 -1 c = c.redMul(this.x.redSub(p.x).redInvm());18696 -1 var nx = c.redSqr().redISub(this.x).redISub(p.x);18697 -1 var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);18698 -1 return this.curve.point(nx, ny);18699 -1 };18700 -118701 -1 Point.prototype.dbl = function dbl() {18702 -1 if (this.inf)18703 -1 return this;18704 -118705 -1 // 2P = O18706 -1 var ys1 = this.y.redAdd(this.y);18707 -1 if (ys1.cmpn(0) === 0)18708 -1 return this.curve.point(null, null);18709 -118710 -1 var a = this.curve.a;18711 -118712 -1 var x2 = this.x.redSqr();18713 -1 var dyinv = ys1.redInvm();18714 -1 var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);18715 -118716 -1 var nx = c.redSqr().redISub(this.x.redAdd(this.x));18717 -1 var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);18718 -1 return this.curve.point(nx, ny);18719 -1 };18720 -118721 -1 Point.prototype.getX = function getX() {18722 -1 return this.x.fromRed();18723 -1 };18724 -118725 -1 Point.prototype.getY = function getY() {18726 -1 return this.y.fromRed();18727 -1 };18728 -118729 -1 Point.prototype.mul = function mul(k) {18730 -1 k = new BN(k, 16);18731 -1 if (this.isInfinity())18732 -1 return this;18733 -1 else if (this._hasDoubles(k))18734 -1 return this.curve._fixedNafMul(this, k);18735 -1 else if (this.curve.endo)18736 -1 return this.curve._endoWnafMulAdd([ this ], [ k ]);18737 -1 else18738 -1 return this.curve._wnafMul(this, k);18739 -1 };18740 -118741 -1 Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {18742 -1 var points = [ this, p2 ];18743 -1 var coeffs = [ k1, k2 ];18744 -1 if (this.curve.endo)18745 -1 return this.curve._endoWnafMulAdd(points, coeffs);18746 -1 else18747 -1 return this.curve._wnafMulAdd(1, points, coeffs, 2);18748 -1 };18749 -118750 -1 Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {18751 -1 var points = [ this, p2 ];18752 -1 var coeffs = [ k1, k2 ];18753 -1 if (this.curve.endo)18754 -1 return this.curve._endoWnafMulAdd(points, coeffs, true);18755 -1 else18756 -1 return this.curve._wnafMulAdd(1, points, coeffs, 2, true);18757 -1 };18758 -118759 -1 Point.prototype.eq = function eq(p) {18760 -1 return this === p ||18761 -1 this.inf === p.inf &&18762 -1 (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);18763 -1 };18764 -118765 -1 Point.prototype.neg = function neg(_precompute) {18766 -1 if (this.inf)18767 -1 return this;18768 -118769 -1 var res = this.curve.point(this.x, this.y.redNeg());18770 -1 if (_precompute && this.precomputed) {18771 -1 var pre = this.precomputed;18772 -1 var negate = function(p) {18773 -1 return p.neg();18774 -1 };18775 -1 res.precomputed = {18776 -1 naf: pre.naf && {18777 -1 wnd: pre.naf.wnd,18778 -1 points: pre.naf.points.map(negate),18779 -1 },18780 -1 doubles: pre.doubles && {18781 -1 step: pre.doubles.step,18782 -1 points: pre.doubles.points.map(negate),18783 -1 },18784 -1 };18785 -1 }18786 -1 return res;18787 -1 };18788 -118789 -1 Point.prototype.toJ = function toJ() {18790 -1 if (this.inf)18791 -1 return this.curve.jpoint(null, null, null);18792 -118793 -1 var res = this.curve.jpoint(this.x, this.y, this.curve.one);18794 -1 return res;18795 -1 };18796 -118797 -1 function JPoint(curve, x, y, z) {18798 -1 Base.BasePoint.call(this, curve, 'jacobian');18799 -1 if (x === null && y === null && z === null) {18800 -1 this.x = this.curve.one;18801 -1 this.y = this.curve.one;18802 -1 this.z = new BN(0);18803 -1 } else {18804 -1 this.x = new BN(x, 16);18805 -1 this.y = new BN(y, 16);18806 -1 this.z = new BN(z, 16);18807 -1 }18808 -1 if (!this.x.red)18809 -1 this.x = this.x.toRed(this.curve.red);18810 -1 if (!this.y.red)18811 -1 this.y = this.y.toRed(this.curve.red);18812 -1 if (!this.z.red)18813 -1 this.z = this.z.toRed(this.curve.red);18814 -118815 -1 this.zOne = this.z === this.curve.one;18816 -1 }18817 -1 inherits(JPoint, Base.BasePoint);18818 -118819 -1 ShortCurve.prototype.jpoint = function jpoint(x, y, z) {18820 -1 return new JPoint(this, x, y, z);18821 -1 };18822 -118823 -1 JPoint.prototype.toP = function toP() {18824 -1 if (this.isInfinity())18825 -1 return this.curve.point(null, null);18826 -118827 -1 var zinv = this.z.redInvm();18828 -1 var zinv2 = zinv.redSqr();18829 -1 var ax = this.x.redMul(zinv2);18830 -1 var ay = this.y.redMul(zinv2).redMul(zinv);18831 -118832 -1 return this.curve.point(ax, ay);18833 -1 };18834 -118835 -1 JPoint.prototype.neg = function neg() {18836 -1 return this.curve.jpoint(this.x, this.y.redNeg(), this.z);18837 -1 };18838 -118839 -1 JPoint.prototype.add = function add(p) {18840 -1 // O + P = P18841 -1 if (this.isInfinity())18842 -1 return p;18843 -118844 -1 // P + O = P18845 -1 if (p.isInfinity())18846 -1 return this;18847 -118848 -1 // 12M + 4S + 7A18849 -1 var pz2 = p.z.redSqr();18850 -1 var z2 = this.z.redSqr();18851 -1 var u1 = this.x.redMul(pz2);18852 -1 var u2 = p.x.redMul(z2);18853 -1 var s1 = this.y.redMul(pz2.redMul(p.z));18854 -1 var s2 = p.y.redMul(z2.redMul(this.z));18855 -118856 -1 var h = u1.redSub(u2);18857 -1 var r = s1.redSub(s2);18858 -1 if (h.cmpn(0) === 0) {18859 -1 if (r.cmpn(0) !== 0)18860 -1 return this.curve.jpoint(null, null, null);18861 -1 else18862 -1 return this.dbl();18863 -1 }18864 -118865 -1 var h2 = h.redSqr();18866 -1 var h3 = h2.redMul(h);18867 -1 var v = u1.redMul(h2);18868 -118869 -1 var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);18870 -1 var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));18871 -1 var nz = this.z.redMul(p.z).redMul(h);18872 -118873 -1 return this.curve.jpoint(nx, ny, nz);18874 -1 };18875 -118876 -1 JPoint.prototype.mixedAdd = function mixedAdd(p) {18877 -1 // O + P = P18878 -1 if (this.isInfinity())18879 -1 return p.toJ();18880 -118881 -1 // P + O = P18882 -1 if (p.isInfinity())18883 -1 return this;18884 -118885 -1 // 8M + 3S + 7A18886 -1 var z2 = this.z.redSqr();18887 -1 var u1 = this.x;18888 -1 var u2 = p.x.redMul(z2);18889 -1 var s1 = this.y;18890 -1 var s2 = p.y.redMul(z2).redMul(this.z);18891 -118892 -1 var h = u1.redSub(u2);18893 -1 var r = s1.redSub(s2);18894 -1 if (h.cmpn(0) === 0) {18895 -1 if (r.cmpn(0) !== 0)18896 -1 return this.curve.jpoint(null, null, null);18897 -1 else18898 -1 return this.dbl();18899 -1 }18900 -118901 -1 var h2 = h.redSqr();18902 -1 var h3 = h2.redMul(h);18903 -1 var v = u1.redMul(h2);18904 -118905 -1 var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);18906 -1 var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));18907 -1 var nz = this.z.redMul(h);18908 -118909 -1 return this.curve.jpoint(nx, ny, nz);18910 -1 };18911 -118912 -1 JPoint.prototype.dblp = function dblp(pow) {18913 -1 if (pow === 0)18914 -1 return this;18915 -1 if (this.isInfinity())18916 -1 return this;18917 -1 if (!pow)18918 -1 return this.dbl();18919 -118920 -1 var i;18921 -1 if (this.curve.zeroA || this.curve.threeA) {18922 -1 var r = this;18923 -1 for (i = 0; i < pow; i++)18924 -1 r = r.dbl();18925 -1 return r;18926 -1 }18927 -118928 -1 // 1M + 2S + 1A + N * (4S + 5M + 8A)18929 -1 // N = 1 => 6M + 6S + 9A18930 -1 var a = this.curve.a;18931 -1 var tinv = this.curve.tinv;18932 -118933 -1 var jx = this.x;18934 -1 var jy = this.y;18935 -1 var jz = this.z;18936 -1 var jz4 = jz.redSqr().redSqr();18937 -118938 -1 // Reuse results18939 -1 var jyd = jy.redAdd(jy);18940 -1 for (i = 0; i < pow; i++) {18941 -1 var jx2 = jx.redSqr();18942 -1 var jyd2 = jyd.redSqr();18943 -1 var jyd4 = jyd2.redSqr();18944 -1 var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));18945 -118946 -1 var t1 = jx.redMul(jyd2);18947 -1 var nx = c.redSqr().redISub(t1.redAdd(t1));18948 -1 var t2 = t1.redISub(nx);18949 -1 var dny = c.redMul(t2);18950 -1 dny = dny.redIAdd(dny).redISub(jyd4);18951 -1 var nz = jyd.redMul(jz);18952 -1 if (i + 1 < pow)18953 -1 jz4 = jz4.redMul(jyd4);18954 -118955 -1 jx = nx;18956 -1 jz = nz;18957 -1 jyd = dny;18958 -1 }18959 -118960 -1 return this.curve.jpoint(jx, jyd.redMul(tinv), jz);18961 -1 };18962 -118963 -1 JPoint.prototype.dbl = function dbl() {18964 -1 if (this.isInfinity())18965 -1 return this;18966 -118967 -1 if (this.curve.zeroA)18968 -1 return this._zeroDbl();18969 -1 else if (this.curve.threeA)18970 -1 return this._threeDbl();18971 -1 else18972 -1 return this._dbl();18973 -1 };18974 -118975 -1 JPoint.prototype._zeroDbl = function _zeroDbl() {18976 -1 var nx;18977 -1 var ny;18978 -1 var nz;18979 -1 // Z = 118980 -1 if (this.zOne) {18981 -1 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html18982 -1 // #doubling-mdbl-2007-bl18983 -1 // 1M + 5S + 14A18984 -118985 -1 // XX = X1^218986 -1 var xx = this.x.redSqr();18987 -1 // YY = Y1^218988 -1 var yy = this.y.redSqr();18989 -1 // YYYY = YY^218990 -1 var yyyy = yy.redSqr();18991 -1 // S = 2 * ((X1 + YY)^2 - XX - YYYY)18992 -1 var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);18993 -1 s = s.redIAdd(s);18994 -1 // M = 3 * XX + a; a = 018995 -1 var m = xx.redAdd(xx).redIAdd(xx);18996 -1 // T = M ^ 2 - 2*S18997 -1 var t = m.redSqr().redISub(s).redISub(s);18998 -118999 -1 // 8 * YYYY19000 -1 var yyyy8 = yyyy.redIAdd(yyyy);19001 -1 yyyy8 = yyyy8.redIAdd(yyyy8);19002 -1 yyyy8 = yyyy8.redIAdd(yyyy8);19003 -119004 -1 // X3 = T19005 -1 nx = t;19006 -1 // Y3 = M * (S - T) - 8 * YYYY19007 -1 ny = m.redMul(s.redISub(t)).redISub(yyyy8);19008 -1 // Z3 = 2*Y119009 -1 nz = this.y.redAdd(this.y);19010 -1 } else {19011 -1 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html19012 -1 // #doubling-dbl-2009-l19013 -1 // 2M + 5S + 13A19014 -119015 -1 // A = X1^219016 -1 var a = this.x.redSqr();19017 -1 // B = Y1^219018 -1 var b = this.y.redSqr();19019 -1 // C = B^219020 -1 var c = b.redSqr();19021 -1 // D = 2 * ((X1 + B)^2 - A - C)19022 -1 var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);19023 -1 d = d.redIAdd(d);19024 -1 // E = 3 * A19025 -1 var e = a.redAdd(a).redIAdd(a);19026 -1 // F = E^219027 -1 var f = e.redSqr();19028 -119029 -1 // 8 * C19030 -1 var c8 = c.redIAdd(c);19031 -1 c8 = c8.redIAdd(c8);19032 -1 c8 = c8.redIAdd(c8);19033 -119034 -1 // X3 = F - 2 * D19035 -1 nx = f.redISub(d).redISub(d);19036 -1 // Y3 = E * (D - X3) - 8 * C19037 -1 ny = e.redMul(d.redISub(nx)).redISub(c8);19038 -1 // Z3 = 2 * Y1 * Z119039 -1 nz = this.y.redMul(this.z);19040 -1 nz = nz.redIAdd(nz);19041 -1 }19042 -119043 -1 return this.curve.jpoint(nx, ny, nz);19044 -1 };19045 -119046 -1 JPoint.prototype._threeDbl = function _threeDbl() {19047 -1 var nx;19048 -1 var ny;19049 -1 var nz;19050 -1 // Z = 119051 -1 if (this.zOne) {19052 -1 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html19053 -1 // #doubling-mdbl-2007-bl19054 -1 // 1M + 5S + 15A19055 -119056 -1 // XX = X1^219057 -1 var xx = this.x.redSqr();19058 -1 // YY = Y1^219059 -1 var yy = this.y.redSqr();19060 -1 // YYYY = YY^219061 -1 var yyyy = yy.redSqr();19062 -1 // S = 2 * ((X1 + YY)^2 - XX - YYYY)19063 -1 var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);19064 -1 s = s.redIAdd(s);19065 -1 // M = 3 * XX + a19066 -1 var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);19067 -1 // T = M^2 - 2 * S19068 -1 var t = m.redSqr().redISub(s).redISub(s);19069 -1 // X3 = T19070 -1 nx = t;19071 -1 // Y3 = M * (S - T) - 8 * YYYY19072 -1 var yyyy8 = yyyy.redIAdd(yyyy);19073 -1 yyyy8 = yyyy8.redIAdd(yyyy8);19074 -1 yyyy8 = yyyy8.redIAdd(yyyy8);19075 -1 ny = m.redMul(s.redISub(t)).redISub(yyyy8);19076 -1 // Z3 = 2 * Y119077 -1 nz = this.y.redAdd(this.y);19078 -1 } else {19079 -1 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b19080 -1 // 3M + 5S19081 -119082 -1 // delta = Z1^219083 -1 var delta = this.z.redSqr();19084 -1 // gamma = Y1^219085 -1 var gamma = this.y.redSqr();19086 -1 // beta = X1 * gamma19087 -1 var beta = this.x.redMul(gamma);19088 -1 // alpha = 3 * (X1 - delta) * (X1 + delta)19089 -1 var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));19090 -1 alpha = alpha.redAdd(alpha).redIAdd(alpha);19091 -1 // X3 = alpha^2 - 8 * beta19092 -1 var beta4 = beta.redIAdd(beta);19093 -1 beta4 = beta4.redIAdd(beta4);19094 -1 var beta8 = beta4.redAdd(beta4);19095 -1 nx = alpha.redSqr().redISub(beta8);19096 -1 // Z3 = (Y1 + Z1)^2 - gamma - delta19097 -1 nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);19098 -1 // Y3 = alpha * (4 * beta - X3) - 8 * gamma^219099 -1 var ggamma8 = gamma.redSqr();19100 -1 ggamma8 = ggamma8.redIAdd(ggamma8);19101 -1 ggamma8 = ggamma8.redIAdd(ggamma8);19102 -1 ggamma8 = ggamma8.redIAdd(ggamma8);19103 -1 ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);19104 -1 }19105 -119106 -1 return this.curve.jpoint(nx, ny, nz);19107 -1 };19108 -119109 -1 JPoint.prototype._dbl = function _dbl() {19110 -1 var a = this.curve.a;19111 -119112 -1 // 4M + 6S + 10A19113 -1 var jx = this.x;19114 -1 var jy = this.y;19115 -1 var jz = this.z;19116 -1 var jz4 = jz.redSqr().redSqr();19117 -119118 -1 var jx2 = jx.redSqr();19119 -1 var jy2 = jy.redSqr();19120 -119121 -1 var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));19122 -119123 -1 var jxd4 = jx.redAdd(jx);19124 -1 jxd4 = jxd4.redIAdd(jxd4);19125 -1 var t1 = jxd4.redMul(jy2);19126 -1 var nx = c.redSqr().redISub(t1.redAdd(t1));19127 -1 var t2 = t1.redISub(nx);19128 -119129 -1 var jyd8 = jy2.redSqr();19130 -1 jyd8 = jyd8.redIAdd(jyd8);19131 -1 jyd8 = jyd8.redIAdd(jyd8);19132 -1 jyd8 = jyd8.redIAdd(jyd8);19133 -1 var ny = c.redMul(t2).redISub(jyd8);19134 -1 var nz = jy.redAdd(jy).redMul(jz);19135 -119136 -1 return this.curve.jpoint(nx, ny, nz);19137 -1 };19138 -119139 -1 JPoint.prototype.trpl = function trpl() {19140 -1 if (!this.curve.zeroA)19141 -1 return this.dbl().add(this);19142 -119143 -1 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl19144 -1 // 5M + 10S + ...19145 -119146 -1 // XX = X1^219147 -1 var xx = this.x.redSqr();19148 -1 // YY = Y1^219149 -1 var yy = this.y.redSqr();19150 -1 // ZZ = Z1^219151 -1 var zz = this.z.redSqr();19152 -1 // YYYY = YY^219153 -1 var yyyy = yy.redSqr();19154 -1 // M = 3 * XX + a * ZZ2; a = 019155 -1 var m = xx.redAdd(xx).redIAdd(xx);19156 -1 // MM = M^219157 -1 var mm = m.redSqr();19158 -1 // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM19159 -1 var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);19160 -1 e = e.redIAdd(e);19161 -1 e = e.redAdd(e).redIAdd(e);19162 -1 e = e.redISub(mm);19163 -1 // EE = E^219164 -1 var ee = e.redSqr();19165 -1 // T = 16*YYYY19166 -1 var t = yyyy.redIAdd(yyyy);19167 -1 t = t.redIAdd(t);19168 -1 t = t.redIAdd(t);19169 -1 t = t.redIAdd(t);19170 -1 // U = (M + E)^2 - MM - EE - T19171 -1 var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);19172 -1 // X3 = 4 * (X1 * EE - 4 * YY * U)19173 -1 var yyu4 = yy.redMul(u);19174 -1 yyu4 = yyu4.redIAdd(yyu4);19175 -1 yyu4 = yyu4.redIAdd(yyu4);19176 -1 var nx = this.x.redMul(ee).redISub(yyu4);19177 -1 nx = nx.redIAdd(nx);19178 -1 nx = nx.redIAdd(nx);19179 -1 // Y3 = 8 * Y1 * (U * (T - U) - E * EE)19180 -1 var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));19181 -1 ny = ny.redIAdd(ny);19182 -1 ny = ny.redIAdd(ny);19183 -1 ny = ny.redIAdd(ny);19184 -1 // Z3 = (Z1 + E)^2 - ZZ - EE19185 -1 var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);19186 -119187 -1 return this.curve.jpoint(nx, ny, nz);19188 -1 };19189 -119190 -1 JPoint.prototype.mul = function mul(k, kbase) {19191 -1 k = new BN(k, kbase);19192 -119193 -1 return this.curve._wnafMul(this, k);19194 -1 };19195 -119196 -1 JPoint.prototype.eq = function eq(p) {19197 -1 if (p.type === 'affine')19198 -1 return this.eq(p.toJ());19199 -119200 -1 if (this === p)19201 -1 return true;19202 -119203 -1 // x1 * z2^2 == x2 * z1^219204 -1 var z2 = this.z.redSqr();19205 -1 var pz2 = p.z.redSqr();19206 -1 if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)19207 -1 return false;19208 -119209 -1 // y1 * z2^3 == y2 * z1^319210 -1 var z3 = z2.redMul(this.z);19211 -1 var pz3 = pz2.redMul(p.z);19212 -1 return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;19213 -1 };19214 -119215 -1 JPoint.prototype.eqXToP = function eqXToP(x) {19216 -1 var zs = this.z.redSqr();19217 -1 var rx = x.toRed(this.curve.red).redMul(zs);19218 -1 if (this.x.cmp(rx) === 0)19219 -1 return true;19220 -119221 -1 var xc = x.clone();19222 -1 var t = this.curve.redN.redMul(zs);19223 -1 for (;;) {19224 -1 xc.iadd(this.curve.n);19225 -1 if (xc.cmp(this.curve.p) >= 0)19226 -1 return false;19227 -119228 -1 rx.redIAdd(t);19229 -1 if (this.x.cmp(rx) === 0)19230 -1 return true;19231 -1 }19232 -1 };19233 -119234 -1 JPoint.prototype.inspect = function inspect() {19235 -1 if (this.isInfinity())19236 -1 return '<EC JPoint Infinity>';19237 -1 return '<EC JPoint x: ' + this.x.toString(16, 2) +19238 -1 ' y: ' + this.y.toString(16, 2) +19239 -1 ' z: ' + this.z.toString(16, 2) + '>';19240 -1 };19241 -119242 -1 JPoint.prototype.isInfinity = function isInfinity() {19243 -1 // XXX This code assumes that zero is always zero in red19244 -1 return this.z.cmpn(0) === 0;19245 -1 };19246 -119247 -1 },{"../utils":97,"./base":84,"bn.js":98,"inherits":132}],89:[function(require,module,exports){19248 -1 'use strict';19249 -119250 -1 var curves = exports;19251 -119252 -1 var hash = require('hash.js');19253 -1 var curve = require('./curve');19254 -1 var utils = require('./utils');19255 -119256 -1 var assert = utils.assert;19257 -119258 -1 function PresetCurve(options) {19259 -1 if (options.type === 'short')19260 -1 this.curve = new curve.short(options);19261 -1 else if (options.type === 'edwards')19262 -1 this.curve = new curve.edwards(options);19263 -1 else19264 -1 this.curve = new curve.mont(options);19265 -1 this.g = this.curve.g;19266 -1 this.n = this.curve.n;19267 -1 this.hash = options.hash;19268 -119269 -1 assert(this.g.validate(), 'Invalid curve');19270 -1 assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');19271 -1 }19272 -1 curves.PresetCurve = PresetCurve;19273 -119274 -1 function defineCurve(name, options) {19275 -1 Object.defineProperty(curves, name, {19276 -1 configurable: true,19277 -1 enumerable: true,19278 -1 get: function() {19279 -1 var curve = new PresetCurve(options);19280 -1 Object.defineProperty(curves, name, {19281 -1 configurable: true,19282 -1 enumerable: true,19283 -1 value: curve,19284 -1 });19285 -1 return curve;19286 -1 },19287 -1 });19288 -1 }19289 -119290 -1 defineCurve('p192', {19291 -1 type: 'short',19292 -1 prime: 'p192',19293 -1 p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',19294 -1 a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',19295 -1 b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',19296 -1 n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',19297 -1 hash: hash.sha256,19298 -1 gRed: false,19299 -1 g: [19300 -1 '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',19301 -1 '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811',19302 -1 ],19303 -1 });19304 -119305 -1 defineCurve('p224', {19306 -1 type: 'short',19307 -1 prime: 'p224',19308 -1 p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',19309 -1 a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',19310 -1 b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',19311 -1 n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',19312 -1 hash: hash.sha256,19313 -1 gRed: false,19314 -1 g: [19315 -1 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',19316 -1 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34',19317 -1 ],19318 -1 });19319 -119320 -1 defineCurve('p256', {19321 -1 type: 'short',19322 -1 prime: null,19323 -1 p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',19324 -1 a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',19325 -1 b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',19326 -1 n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',19327 -1 hash: hash.sha256,19328 -1 gRed: false,19329 -1 g: [19330 -1 '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',19331 -1 '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5',19332 -1 ],19333 -1 });19334 -119335 -1 defineCurve('p384', {19336 -1 type: 'short',19337 -1 prime: null,19338 -1 p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +19339 -1 'fffffffe ffffffff 00000000 00000000 ffffffff',19340 -1 a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +19341 -1 'fffffffe ffffffff 00000000 00000000 fffffffc',19342 -1 b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +19343 -1 '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',19344 -1 n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +19345 -1 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',19346 -1 hash: hash.sha384,19347 -1 gRed: false,19348 -1 g: [19349 -1 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +19350 -1 '5502f25d bf55296c 3a545e38 72760ab7',19351 -1 '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +19352 -1 '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f',19353 -1 ],19354 -1 });19355 -119356 -1 defineCurve('p521', {19357 -1 type: 'short',19358 -1 prime: null,19359 -1 p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +19360 -1 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +19361 -1 'ffffffff ffffffff ffffffff ffffffff ffffffff',19362 -1 a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +19363 -1 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +19364 -1 'ffffffff ffffffff ffffffff ffffffff fffffffc',19365 -1 b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +19366 -1 '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +19367 -1 '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',19368 -1 n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +19369 -1 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +19370 -1 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',19371 -1 hash: hash.sha512,19372 -1 gRed: false,19373 -1 g: [19374 -1 '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +19375 -1 '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +19376 -1 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',19377 -1 '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +19378 -1 '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +19379 -1 '3fad0761 353c7086 a272c240 88be9476 9fd16650',19380 -1 ],19381 -1 });19382 -119383 -1 defineCurve('curve25519', {19384 -1 type: 'mont',19385 -1 prime: 'p25519',19386 -1 p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',19387 -1 a: '76d06',19388 -1 b: '1',19389 -1 n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',19390 -1 hash: hash.sha256,19391 -1 gRed: false,19392 -1 g: [19393 -1 '9',19394 -1 ],19395 -1 });19396 -119397 -1 defineCurve('ed25519', {19398 -1 type: 'edwards',19399 -1 prime: 'p25519',19400 -1 p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',19401 -1 a: '-1',19402 -1 c: '1',19403 -1 // -121665 * (121666^(-1)) (mod P)19404 -1 d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',19405 -1 n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',19406 -1 hash: hash.sha256,19407 -1 gRed: false,19408 -1 g: [19409 -1 '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',19410 -119411 -1 // 4/519412 -1 '6666666666666666666666666666666666666666666666666666666666666658',19413 -1 ],19414 -1 });19415 -119416 -1 var pre;19417 -1 try {19418 -1 pre = require('./precomputed/secp256k1');19419 -1 } catch (e) {19420 -1 pre = undefined;19421 -1 }19422 -119423 -1 defineCurve('secp256k1', {19424 -1 type: 'short',19425 -1 prime: 'k256',19426 -1 p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',19427 -1 a: '0',19428 -1 b: '7',19429 -1 n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',19430 -1 h: '1',19431 -1 hash: hash.sha256,19432 -119433 -1 // Precomputed endomorphism19434 -1 beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',19435 -1 lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',19436 -1 basis: [19437 -1 {19438 -1 a: '3086d221a7d46bcde86c90e49284eb15',19439 -1 b: '-e4437ed6010e88286f547fa90abfe4c3',19440 -1 },19441 -1 {19442 -1 a: '114ca50f7a8e2f3f657c1108d9d44cfd8',19443 -1 b: '3086d221a7d46bcde86c90e49284eb15',19444 -1 },19445 -1 ],19446 -119447 -1 gRed: false,19448 -1 g: [19449 -1 '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',19450 -1 '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',19451 -1 pre,19452 -1 ],19453 -1 });19454 -119455 -1 },{"./curve":86,"./precomputed/secp256k1":96,"./utils":97,"hash.js":118}],90:[function(require,module,exports){19456 -1 'use strict';19457 -119458 -1 var BN = require('bn.js');19459 -1 var HmacDRBG = require('hmac-drbg');19460 -1 var utils = require('../utils');19461 -1 var curves = require('../curves');19462 -1 var rand = require('brorand');19463 -1 var assert = utils.assert;19464 -119465 -1 var KeyPair = require('./key');19466 -1 var Signature = require('./signature');19467 -119468 -1 function EC(options) {19469 -1 if (!(this instanceof EC))19470 -1 return new EC(options);19471 -119472 -1 // Shortcut `elliptic.ec(curve-name)`19473 -1 if (typeof options === 'string') {19474 -1 assert(Object.prototype.hasOwnProperty.call(curves, options),19475 -1 'Unknown curve ' + options);19476 -119477 -1 options = curves[options];19478 -1 }19479 -119480 -1 // Shortcut for `elliptic.ec(elliptic.curves.curveName)`19481 -1 if (options instanceof curves.PresetCurve)19482 -1 options = { curve: options };19483 -119484 -1 this.curve = options.curve.curve;19485 -1 this.n = this.curve.n;19486 -1 this.nh = this.n.ushrn(1);19487 -1 this.g = this.curve.g;19488 -119489 -1 // Point on curve19490 -1 this.g = options.curve.g;19491 -1 this.g.precompute(options.curve.n.bitLength() + 1);19492 -119493 -1 // Hash for function for DRBG19494 -1 this.hash = options.hash || options.curve.hash;19495 -1 }19496 -1 module.exports = EC;19497 -119498 -1 EC.prototype.keyPair = function keyPair(options) {19499 -1 return new KeyPair(this, options);19500 -1 };19501 -119502 -1 EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {19503 -1 return KeyPair.fromPrivate(this, priv, enc);19504 -1 };19505 -119506 -1 EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {19507 -1 return KeyPair.fromPublic(this, pub, enc);19508 -1 };19509 -119510 -1 EC.prototype.genKeyPair = function genKeyPair(options) {19511 -1 if (!options)19512 -1 options = {};19513 -119514 -1 // Instantiate Hmac_DRBG19515 -1 var drbg = new HmacDRBG({19516 -1 hash: this.hash,19517 -1 pers: options.pers,19518 -1 persEnc: options.persEnc || 'utf8',19519 -1 entropy: options.entropy || rand(this.hash.hmacStrength),19520 -1 entropyEnc: options.entropy && options.entropyEnc || 'utf8',19521 -1 nonce: this.n.toArray(),19522 -1 });19523 -119524 -1 var bytes = this.n.byteLength();19525 -1 var ns2 = this.n.sub(new BN(2));19526 -1 for (;;) {19527 -1 var priv = new BN(drbg.generate(bytes));19528 -1 if (priv.cmp(ns2) > 0)19529 -1 continue;19530 -119531 -1 priv.iaddn(1);19532 -1 return this.keyFromPrivate(priv);19533 -1 }19534 -1 };19535 -119536 -1 EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) {19537 -1 var delta = msg.byteLength() * 8 - this.n.bitLength();19538 -1 if (delta > 0)19539 -1 msg = msg.ushrn(delta);19540 -1 if (!truncOnly && msg.cmp(this.n) >= 0)19541 -1 return msg.sub(this.n);19542 -1 else19543 -1 return msg;19544 -1 };19545 -119546 -1 EC.prototype.sign = function sign(msg, key, enc, options) {19547 -1 if (typeof enc === 'object') {19548 -1 options = enc;19549 -1 enc = null;19550 -1 }19551 -1 if (!options)19552 -1 options = {};19553 -119554 -1 key = this.keyFromPrivate(key, enc);19555 -1 msg = this._truncateToN(new BN(msg, 16));19556 -119557 -1 // Zero-extend key to provide enough entropy19558 -1 var bytes = this.n.byteLength();19559 -1 var bkey = key.getPrivate().toArray('be', bytes);19560 -119561 -1 // Zero-extend nonce to have the same byte size as N19562 -1 var nonce = msg.toArray('be', bytes);19563 -119564 -1 // Instantiate Hmac_DRBG19565 -1 var drbg = new HmacDRBG({19566 -1 hash: this.hash,19567 -1 entropy: bkey,19568 -1 nonce: nonce,19569 -1 pers: options.pers,19570 -1 persEnc: options.persEnc || 'utf8',19571 -1 });19572 -119573 -1 // Number of bytes to generate19574 -1 var ns1 = this.n.sub(new BN(1));19575 -119576 -1 for (var iter = 0; ; iter++) {19577 -1 var k = options.k ?19578 -1 options.k(iter) :19579 -1 new BN(drbg.generate(this.n.byteLength()));19580 -1 k = this._truncateToN(k, true);19581 -1 if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)19582 -1 continue;19583 -119584 -1 var kp = this.g.mul(k);19585 -1 if (kp.isInfinity())19586 -1 continue;19587 -119588 -1 var kpX = kp.getX();19589 -1 var r = kpX.umod(this.n);19590 -1 if (r.cmpn(0) === 0)19591 -1 continue;19592 -119593 -1 var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));19594 -1 s = s.umod(this.n);19595 -1 if (s.cmpn(0) === 0)19596 -1 continue;19597 -119598 -1 var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |19599 -1 (kpX.cmp(r) !== 0 ? 2 : 0);19600 -119601 -1 // Use complement of `s`, if it is > `n / 2`19602 -1 if (options.canonical && s.cmp(this.nh) > 0) {19603 -1 s = this.n.sub(s);19604 -1 recoveryParam ^= 1;19605 -1 }19606 -119607 -1 return new Signature({ r: r, s: s, recoveryParam: recoveryParam });19608 -1 }19609 -1 };19610 -119611 -1 EC.prototype.verify = function verify(msg, signature, key, enc) {19612 -1 msg = this._truncateToN(new BN(msg, 16));19613 -1 key = this.keyFromPublic(key, enc);19614 -1 signature = new Signature(signature, 'hex');19615 -119616 -1 // Perform primitive values validation19617 -1 var r = signature.r;19618 -1 var s = signature.s;19619 -1 if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)19620 -1 return false;19621 -1 if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)19622 -1 return false;19623 -119624 -1 // Validate signature19625 -1 var sinv = s.invm(this.n);19626 -1 var u1 = sinv.mul(msg).umod(this.n);19627 -1 var u2 = sinv.mul(r).umod(this.n);19628 -1 var p;19629 -119630 -1 if (!this.curve._maxwellTrick) {19631 -1 p = this.g.mulAdd(u1, key.getPublic(), u2);19632 -1 if (p.isInfinity())19633 -1 return false;19634 -119635 -1 return p.getX().umod(this.n).cmp(r) === 0;19636 -1 }19637 -119638 -1 // NOTE: Greg Maxwell's trick, inspired by:19639 -1 // https://git.io/vad3K19640 -119641 -1 p = this.g.jmulAdd(u1, key.getPublic(), u2);19642 -1 if (p.isInfinity())19643 -1 return false;19644 -119645 -1 // Compare `p.x` of Jacobian point with `r`,19646 -1 // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the19647 -1 // inverse of `p.z^2`19648 -1 return p.eqXToP(r);19649 -1 };19650 -119651 -1 EC.prototype.recoverPubKey = function(msg, signature, j, enc) {19652 -1 assert((3 & j) === j, 'The recovery param is more than two bits');19653 -1 signature = new Signature(signature, enc);19654 -119655 -1 var n = this.n;19656 -1 var e = new BN(msg);19657 -1 var r = signature.r;19658 -1 var s = signature.s;19659 -119660 -1 // A set LSB signifies that the y-coordinate is odd19661 -1 var isYOdd = j & 1;19662 -1 var isSecondKey = j >> 1;19663 -1 if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)19664 -1 throw new Error('Unable to find sencond key candinate');19665 -119666 -1 // 1.1. Let x = r + jn.19667 -1 if (isSecondKey)19668 -1 r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);19669 -1 else19670 -1 r = this.curve.pointFromX(r, isYOdd);19671 -119672 -1 var rInv = signature.r.invm(n);19673 -1 var s1 = n.sub(e).mul(rInv).umod(n);19674 -1 var s2 = s.mul(rInv).umod(n);19675 -119676 -1 // 1.6.1 Compute Q = r^-1 (sR - eG)19677 -1 // Q = r^-1 (sR + -eG)19678 -1 return this.g.mulAdd(s1, r, s2);19679 -1 };19680 -119681 -1 EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {19682 -1 signature = new Signature(signature, enc);19683 -1 if (signature.recoveryParam !== null)19684 -1 return signature.recoveryParam;19685 -119686 -1 for (var i = 0; i < 4; i++) {19687 -1 var Qprime;19688 -1 try {19689 -1 Qprime = this.recoverPubKey(e, signature, i);19690 -1 } catch (e) {19691 -1 continue;19692 -1 }19693 -119694 -1 if (Qprime.eq(Q))19695 -1 return i;19696 -1 }19697 -1 throw new Error('Unable to find valid recovery factor');19698 -1 };19699 -119700 -1 },{"../curves":89,"../utils":97,"./key":91,"./signature":92,"bn.js":98,"brorand":18,"hmac-drbg":130}],91:[function(require,module,exports){19701 -1 'use strict';19702 -119703 -1 var BN = require('bn.js');19704 -1 var utils = require('../utils');19705 -1 var assert = utils.assert;19706 -119707 -1 function KeyPair(ec, options) {19708 -1 this.ec = ec;19709 -1 this.priv = null;19710 -1 this.pub = null;19711 -119712 -1 // KeyPair(ec, { priv: ..., pub: ... })19713 -1 if (options.priv)19714 -1 this._importPrivate(options.priv, options.privEnc);19715 -1 if (options.pub)19716 -1 this._importPublic(options.pub, options.pubEnc);19717 -1 }19718 -1 module.exports = KeyPair;19719 -119720 -1 KeyPair.fromPublic = function fromPublic(ec, pub, enc) {19721 -1 if (pub instanceof KeyPair)19722 -1 return pub;19723 -119724 -1 return new KeyPair(ec, {19725 -1 pub: pub,19726 -1 pubEnc: enc,19727 -1 });19728 -1 };19729 -119730 -1 KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {19731 -1 if (priv instanceof KeyPair)19732 -1 return priv;19733 -119734 -1 return new KeyPair(ec, {19735 -1 priv: priv,19736 -1 privEnc: enc,19737 -1 });19738 -1 };19739 -119740 -1 KeyPair.prototype.validate = function validate() {19741 -1 var pub = this.getPublic();19742 -119743 -1 if (pub.isInfinity())19744 -1 return { result: false, reason: 'Invalid public key' };19745 -1 if (!pub.validate())19746 -1 return { result: false, reason: 'Public key is not a point' };19747 -1 if (!pub.mul(this.ec.curve.n).isInfinity())19748 -1 return { result: false, reason: 'Public key * N != O' };19749 -119750 -1 return { result: true, reason: null };19751 -1 };19752 -119753 -1 KeyPair.prototype.getPublic = function getPublic(compact, enc) {19754 -1 // compact is optional argument19755 -1 if (typeof compact === 'string') {19756 -1 enc = compact;19757 -1 compact = null;19758 -1 }19759 -119760 -1 if (!this.pub)19761 -1 this.pub = this.ec.g.mul(this.priv);19762 -119763 -1 if (!enc)19764 -1 return this.pub;19765 -119766 -1 return this.pub.encode(enc, compact);19767 -1 };19768 -119769 -1 KeyPair.prototype.getPrivate = function getPrivate(enc) {19770 -1 if (enc === 'hex')19771 -1 return this.priv.toString(16, 2);19772 -1 else19773 -1 return this.priv;19774 -1 };19775 -119776 -1 KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {19777 -1 this.priv = new BN(key, enc || 16);19778 -119779 -1 // Ensure that the priv won't be bigger than n, otherwise we may fail19780 -1 // in fixed multiplication method19781 -1 this.priv = this.priv.umod(this.ec.curve.n);19782 -1 };19783 -119784 -1 KeyPair.prototype._importPublic = function _importPublic(key, enc) {19785 -1 if (key.x || key.y) {19786 -1 // Montgomery points only have an `x` coordinate.19787 -1 // Weierstrass/Edwards points on the other hand have both `x` and19788 -1 // `y` coordinates.19789 -1 if (this.ec.curve.type === 'mont') {19790 -1 assert(key.x, 'Need x coordinate');19791 -1 } else if (this.ec.curve.type === 'short' ||19792 -1 this.ec.curve.type === 'edwards') {19793 -1 assert(key.x && key.y, 'Need both x and y coordinate');19794 -1 }19795 -1 this.pub = this.ec.curve.point(key.x, key.y);19796 -1 return;19797 -1 }19798 -1 this.pub = this.ec.curve.decodePoint(key, enc);19799 -1 };19800 -119801 -1 // ECDH19802 -1 KeyPair.prototype.derive = function derive(pub) {19803 -1 if(!pub.validate()) {19804 -1 assert(pub.validate(), 'public point not validated');19805 -1 }19806 -1 return pub.mul(this.priv).getX();19807 -1 };19808 -119809 -1 // ECDSA19810 -1 KeyPair.prototype.sign = function sign(msg, enc, options) {19811 -1 return this.ec.sign(msg, this, enc, options);19812 -1 };19813 -119814 -1 KeyPair.prototype.verify = function verify(msg, signature) {19815 -1 return this.ec.verify(msg, signature, this);19816 -1 };19817 -119818 -1 KeyPair.prototype.inspect = function inspect() {19819 -1 return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +19820 -1 ' pub: ' + (this.pub && this.pub.inspect()) + ' >';19821 -1 };19822 -119823 -1 },{"../utils":97,"bn.js":98}],92:[function(require,module,exports){19824 -1 'use strict';19825 -119826 -1 var BN = require('bn.js');19827 -119828 -1 var utils = require('../utils');19829 -1 var assert = utils.assert;19830 -119831 -1 function Signature(options, enc) {19832 -1 if (options instanceof Signature)19833 -1 return options;19834 -119835 -1 if (this._importDER(options, enc))19836 -1 return;19837 -119838 -1 assert(options.r && options.s, 'Signature without r or s');19839 -1 this.r = new BN(options.r, 16);19840 -1 this.s = new BN(options.s, 16);19841 -1 if (options.recoveryParam === undefined)19842 -1 this.recoveryParam = null;19843 -1 else19844 -1 this.recoveryParam = options.recoveryParam;19845 -1 }19846 -1 module.exports = Signature;19847 -119848 -1 function Position() {19849 -1 this.place = 0;19850 -1 }19851 -119852 -1 function getLength(buf, p) {19853 -1 var initial = buf[p.place++];19854 -1 if (!(initial & 0x80)) {19855 -1 return initial;19856 -1 }19857 -1 var octetLen = initial & 0xf;19858 -119859 -1 // Indefinite length or overflow19860 -1 if (octetLen === 0 || octetLen > 4) {19861 -1 return false;19862 -1 }19863 -119864 -1 var val = 0;19865 -1 for (var i = 0, off = p.place; i < octetLen; i++, off++) {19866 -1 val <<= 8;19867 -1 val |= buf[off];19868 -1 val >>>= 0;19869 -1 }19870 -119871 -1 // Leading zeroes19872 -1 if (val <= 0x7f) {19873 -1 return false;19874 -1 }19875 -119876 -1 p.place = off;19877 -1 return val;19878 -1 }19879 -119880 -1 function rmPadding(buf) {19881 -1 var i = 0;19882 -1 var len = buf.length - 1;19883 -1 while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {19884 -1 i++;19885 -1 }19886 -1 if (i === 0) {19887 -1 return buf;19888 -1 }19889 -1 return buf.slice(i);19890 -1 }19891 -119892 -1 Signature.prototype._importDER = function _importDER(data, enc) {19893 -1 data = utils.toArray(data, enc);19894 -1 var p = new Position();19895 -1 if (data[p.place++] !== 0x30) {19896 -1 return false;19897 -1 }19898 -1 var len = getLength(data, p);19899 -1 if (len === false) {19900 -1 return false;19901 -1 }19902 -1 if ((len + p.place) !== data.length) {19903 -1 return false;19904 -1 }19905 -1 if (data[p.place++] !== 0x02) {19906 -1 return false;19907 -1 }19908 -1 var rlen = getLength(data, p);19909 -1 if (rlen === false) {19910 -1 return false;19911 -1 }19912 -1 var r = data.slice(p.place, rlen + p.place);19913 -1 p.place += rlen;19914 -1 if (data[p.place++] !== 0x02) {19915 -1 return false;19916 -1 }19917 -1 var slen = getLength(data, p);19918 -1 if (slen === false) {19919 -1 return false;19920 -1 }19921 -1 if (data.length !== slen + p.place) {19922 -1 return false;19923 -1 }19924 -1 var s = data.slice(p.place, slen + p.place);19925 -1 if (r[0] === 0) {19926 -1 if (r[1] & 0x80) {19927 -1 r = r.slice(1);19928 -1 } else {19929 -1 // Leading zeroes19930 -1 return false;19931 -1 }19932 -1 }19933 -1 if (s[0] === 0) {19934 -1 if (s[1] & 0x80) {19935 -1 s = s.slice(1);19936 -1 } else {19937 -1 // Leading zeroes19938 -1 return false;19939 -1 }19940 -1 }19941 -119942 -1 this.r = new BN(r);19943 -1 this.s = new BN(s);19944 -1 this.recoveryParam = null;19945 -119946 -1 return true;19947 -1 };19948 -119949 -1 function constructLength(arr, len) {19950 -1 if (len < 0x80) {19951 -1 arr.push(len);19952 -1 return;19953 -1 }19954 -1 var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);19955 -1 arr.push(octets | 0x80);19956 -1 while (--octets) {19957 -1 arr.push((len >>> (octets << 3)) & 0xff);19958 -1 }19959 -1 arr.push(len);19960 -1 }19961 -119962 -1 Signature.prototype.toDER = function toDER(enc) {19963 -1 var r = this.r.toArray();19964 -1 var s = this.s.toArray();19965 -119966 -1 // Pad values19967 -1 if (r[0] & 0x80)19968 -1 r = [ 0 ].concat(r);19969 -1 // Pad values19970 -1 if (s[0] & 0x80)19971 -1 s = [ 0 ].concat(s);19972 -119973 -1 r = rmPadding(r);19974 -1 s = rmPadding(s);19975 -119976 -1 while (!s[0] && !(s[1] & 0x80)) {19977 -1 s = s.slice(1);19978 -1 }19979 -1 var arr = [ 0x02 ];19980 -1 constructLength(arr, r.length);19981 -1 arr = arr.concat(r);19982 -1 arr.push(0x02);19983 -1 constructLength(arr, s.length);19984 -1 var backHalf = arr.concat(s);19985 -1 var res = [ 0x30 ];19986 -1 constructLength(res, backHalf.length);19987 -1 res = res.concat(backHalf);19988 -1 return utils.encode(res, enc);19989 -1 };19990 -119991 -1 },{"../utils":97,"bn.js":98}],93:[function(require,module,exports){19992 -1 'use strict';19993 -119994 -1 var hash = require('hash.js');19995 -1 var curves = require('../curves');19996 -1 var utils = require('../utils');19997 -1 var assert = utils.assert;19998 -1 var parseBytes = utils.parseBytes;19999 -1 var KeyPair = require('./key');20000 -1 var Signature = require('./signature');20001 -120002 -1 function EDDSA(curve) {20003 -1 assert(curve === 'ed25519', 'only tested with ed25519 so far');20004 -120005 -1 if (!(this instanceof EDDSA))20006 -1 return new EDDSA(curve);20007 -120008 -1 curve = curves[curve].curve;20009 -1 this.curve = curve;20010 -1 this.g = curve.g;20011 -1 this.g.precompute(curve.n.bitLength() + 1);20012 -120013 -1 this.pointClass = curve.point().constructor;20014 -1 this.encodingLength = Math.ceil(curve.n.bitLength() / 8);20015 -1 this.hash = hash.sha512;20016 -1 }20017 -120018 -1 module.exports = EDDSA;20019 -120020 -1 /**20021 -1 * @param {Array|String} message - message bytes20022 -1 * @param {Array|String|KeyPair} secret - secret bytes or a keypair20023 -1 * @returns {Signature} - signature20024 -1 */20025 -1 EDDSA.prototype.sign = function sign(message, secret) {20026 -1 message = parseBytes(message);20027 -1 var key = this.keyFromSecret(secret);20028 -1 var r = this.hashInt(key.messagePrefix(), message);20029 -1 var R = this.g.mul(r);20030 -1 var Rencoded = this.encodePoint(R);20031 -1 var s_ = this.hashInt(Rencoded, key.pubBytes(), message)20032 -1 .mul(key.priv());20033 -1 var S = r.add(s_).umod(this.curve.n);20034 -1 return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });20035 -1 };20036 -120037 -1 /**20038 -1 * @param {Array} message - message bytes20039 -1 * @param {Array|String|Signature} sig - sig bytes20040 -1 * @param {Array|String|Point|KeyPair} pub - public key20041 -1 * @returns {Boolean} - true if public key matches sig of message20042 -1 */20043 -1 EDDSA.prototype.verify = function verify(message, sig, pub) {20044 -1 message = parseBytes(message);20045 -1 sig = this.makeSignature(sig);20046 -1 var key = this.keyFromPublic(pub);20047 -1 var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);20048 -1 var SG = this.g.mul(sig.S());20049 -1 var RplusAh = sig.R().add(key.pub().mul(h));20050 -1 return RplusAh.eq(SG);20051 -1 };20052 -120053 -1 EDDSA.prototype.hashInt = function hashInt() {20054 -1 var hash = this.hash();20055 -1 for (var i = 0; i < arguments.length; i++)20056 -1 hash.update(arguments[i]);20057 -1 return utils.intFromLE(hash.digest()).umod(this.curve.n);20058 -1 };20059 -120060 -1 EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {20061 -1 return KeyPair.fromPublic(this, pub);20062 -1 };20063 -120064 -1 EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {20065 -1 return KeyPair.fromSecret(this, secret);20066 -1 };20067 -120068 -1 EDDSA.prototype.makeSignature = function makeSignature(sig) {20069 -1 if (sig instanceof Signature)20070 -1 return sig;20071 -1 return new Signature(this, sig);20072 -1 };20073 -120074 -1 /**20075 -1 * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.220076 -1 *20077 -1 * EDDSA defines methods for encoding and decoding points and integers. These are20078 -1 * helper convenience methods, that pass along to utility functions implied20079 -1 * parameters.20080 -1 *20081 -1 */20082 -1 EDDSA.prototype.encodePoint = function encodePoint(point) {20083 -1 var enc = point.getY().toArray('le', this.encodingLength);20084 -1 enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;20085 -1 return enc;20086 -1 };20087 -120088 -1 EDDSA.prototype.decodePoint = function decodePoint(bytes) {20089 -1 bytes = utils.parseBytes(bytes);20090 -120091 -1 var lastIx = bytes.length - 1;20092 -1 var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);20093 -1 var xIsOdd = (bytes[lastIx] & 0x80) !== 0;20094 -120095 -1 var y = utils.intFromLE(normed);20096 -1 return this.curve.pointFromY(y, xIsOdd);20097 -1 };20098 -120099 -1 EDDSA.prototype.encodeInt = function encodeInt(num) {20100 -1 return num.toArray('le', this.encodingLength);20101 -1 };20102 -120103 -1 EDDSA.prototype.decodeInt = function decodeInt(bytes) {20104 -1 return utils.intFromLE(bytes);20105 -1 };20106 -120107 -1 EDDSA.prototype.isPoint = function isPoint(val) {20108 -1 return val instanceof this.pointClass;20109 -1 };20110 -120111 -1 },{"../curves":89,"../utils":97,"./key":94,"./signature":95,"hash.js":118}],94:[function(require,module,exports){20112 -1 'use strict';20113 -120114 -1 var utils = require('../utils');20115 -1 var assert = utils.assert;20116 -1 var parseBytes = utils.parseBytes;20117 -1 var cachedProperty = utils.cachedProperty;20118 -120119 -1 /**20120 -1 * @param {EDDSA} eddsa - instance20121 -1 * @param {Object} params - public/private key parameters20122 -1 *20123 -1 * @param {Array<Byte>} [params.secret] - secret seed bytes20124 -1 * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)20125 -1 * @param {Array<Byte>} [params.pub] - public key point encoded as bytes20126 -1 *20127 -1 */20128 -1 function KeyPair(eddsa, params) {20129 -1 this.eddsa = eddsa;20130 -1 this._secret = parseBytes(params.secret);20131 -1 if (eddsa.isPoint(params.pub))20132 -1 this._pub = params.pub;20133 -1 else20134 -1 this._pubBytes = parseBytes(params.pub);20135 -1 }20136 -120137 -1 KeyPair.fromPublic = function fromPublic(eddsa, pub) {20138 -1 if (pub instanceof KeyPair)20139 -1 return pub;20140 -1 return new KeyPair(eddsa, { pub: pub });20141 -1 };20142 -120143 -1 KeyPair.fromSecret = function fromSecret(eddsa, secret) {20144 -1 if (secret instanceof KeyPair)20145 -1 return secret;20146 -1 return new KeyPair(eddsa, { secret: secret });20147 -1 };20148 -120149 -1 KeyPair.prototype.secret = function secret() {20150 -1 return this._secret;20151 -1 };20152 -120153 -1 cachedProperty(KeyPair, 'pubBytes', function pubBytes() {20154 -1 return this.eddsa.encodePoint(this.pub());20155 -1 });20156 -120157 -1 cachedProperty(KeyPair, 'pub', function pub() {20158 -1 if (this._pubBytes)20159 -1 return this.eddsa.decodePoint(this._pubBytes);20160 -1 return this.eddsa.g.mul(this.priv());20161 -1 });20162 -120163 -1 cachedProperty(KeyPair, 'privBytes', function privBytes() {20164 -1 var eddsa = this.eddsa;20165 -1 var hash = this.hash();20166 -1 var lastIx = eddsa.encodingLength - 1;20167 -120168 -1 var a = hash.slice(0, eddsa.encodingLength);20169 -1 a[0] &= 248;20170 -1 a[lastIx] &= 127;20171 -1 a[lastIx] |= 64;20172 -120173 -1 return a;20174 -1 });20175 -120176 -1 cachedProperty(KeyPair, 'priv', function priv() {20177 -1 return this.eddsa.decodeInt(this.privBytes());20178 -1 });20179 -120180 -1 cachedProperty(KeyPair, 'hash', function hash() {20181 -1 return this.eddsa.hash().update(this.secret()).digest();20182 -1 });20183 -120184 -1 cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {20185 -1 return this.hash().slice(this.eddsa.encodingLength);20186 -1 });20187 -120188 -1 KeyPair.prototype.sign = function sign(message) {20189 -1 assert(this._secret, 'KeyPair can only verify');20190 -1 return this.eddsa.sign(message, this);20191 -1 };20192 -120193 -1 KeyPair.prototype.verify = function verify(message, sig) {20194 -1 return this.eddsa.verify(message, sig, this);20195 -1 };20196 -120197 -1 KeyPair.prototype.getSecret = function getSecret(enc) {20198 -1 assert(this._secret, 'KeyPair is public only');20199 -1 return utils.encode(this.secret(), enc);20200 -1 };20201 -120202 -1 KeyPair.prototype.getPublic = function getPublic(enc) {20203 -1 return utils.encode(this.pubBytes(), enc);20204 -1 };20205 -120206 -1 module.exports = KeyPair;20207 -120208 -1 },{"../utils":97}],95:[function(require,module,exports){20209 -1 'use strict';20210 -120211 -1 var BN = require('bn.js');20212 -1 var utils = require('../utils');20213 -1 var assert = utils.assert;20214 -1 var cachedProperty = utils.cachedProperty;20215 -1 var parseBytes = utils.parseBytes;20216 -120217 -1 /**20218 -1 * @param {EDDSA} eddsa - eddsa instance20219 -1 * @param {Array<Bytes>|Object} sig -20220 -1 * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes20221 -1 * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes20222 -1 * @param {Array<Bytes>} [sig.Rencoded] - R point encoded20223 -1 * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded20224 -1 */20225 -1 function Signature(eddsa, sig) {20226 -1 this.eddsa = eddsa;20227 -120228 -1 if (typeof sig !== 'object')20229 -1 sig = parseBytes(sig);20230 -120231 -1 if (Array.isArray(sig)) {20232 -1 sig = {20233 -1 R: sig.slice(0, eddsa.encodingLength),20234 -1 S: sig.slice(eddsa.encodingLength),20235 -1 };20236 -1 }20237 -120238 -1 assert(sig.R && sig.S, 'Signature without R or S');20239 -120240 -1 if (eddsa.isPoint(sig.R))20241 -1 this._R = sig.R;20242 -1 if (sig.S instanceof BN)20243 -1 this._S = sig.S;20244 -120245 -1 this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;20246 -1 this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;20247 -1 }20248 -120249 -1 cachedProperty(Signature, 'S', function S() {20250 -1 return this.eddsa.decodeInt(this.Sencoded());20251 -1 });20252 -120253 -1 cachedProperty(Signature, 'R', function R() {20254 -1 return this.eddsa.decodePoint(this.Rencoded());20255 -1 });20256 -120257 -1 cachedProperty(Signature, 'Rencoded', function Rencoded() {20258 -1 return this.eddsa.encodePoint(this.R());20259 -1 });20260 -120261 -1 cachedProperty(Signature, 'Sencoded', function Sencoded() {20262 -1 return this.eddsa.encodeInt(this.S());20263 -1 });20264 -120265 -1 Signature.prototype.toBytes = function toBytes() {20266 -1 return this.Rencoded().concat(this.Sencoded());20267 -1 };20268 -120269 -1 Signature.prototype.toHex = function toHex() {20270 -1 return utils.encode(this.toBytes(), 'hex').toUpperCase();20271 -1 };20272 -120273 -1 module.exports = Signature;20274 -120275 -1 },{"../utils":97,"bn.js":98}],96:[function(require,module,exports){20276 -1 module.exports = {20277 -1 doubles: {20278 -1 step: 4,20279 -1 points: [20280 -1 [20281 -1 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',20282 -1 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821',20283 -1 ],20284 -1 [20285 -1 '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',20286 -1 '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf',20287 -1 ],20288 -1 [20289 -1 '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',20290 -1 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695',20291 -1 ],20292 -1 [20293 -1 '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',20294 -1 '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9',20295 -1 ],20296 -1 [20297 -1 '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',20298 -1 '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36',20299 -1 ],20300 -1 [20301 -1 '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',20302 -1 '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f',20303 -1 ],20304 -1 [20305 -1 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',20306 -1 '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999',20307 -1 ],20308 -1 [20309 -1 '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',20310 -1 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09',20311 -1 ],20312 -1 [20313 -1 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',20314 -1 '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d',20315 -1 ],20316 -1 [20317 -1 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',20318 -1 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088',20319 -1 ],20320 -1 [20321 -1 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',20322 -1 '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d',20323 -1 ],20324 -1 [20325 -1 '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',20326 -1 '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8',20327 -1 ],20328 -1 [20329 -1 '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',20330 -1 '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a',20331 -1 ],20332 -1 [20333 -1 '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',20334 -1 '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453',20335 -1 ],20336 -1 [20337 -1 '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',20338 -1 '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160',20339 -1 ],20340 -1 [20341 -1 '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',20342 -1 '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0',20343 -1 ],20344 -1 [20345 -1 '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',20346 -1 '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6',20347 -1 ],20348 -1 [20349 -1 '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',20350 -1 '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589',20351 -1 ],20352 -1 [20353 -1 '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',20354 -1 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17',20355 -1 ],20356 -1 [20357 -1 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',20358 -1 '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda',20359 -1 ],20360 -1 [20361 -1 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',20362 -1 '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd',20363 -1 ],20364 -1 [20365 -1 '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',20366 -1 '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2',20367 -1 ],20368 -1 [20369 -1 '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',20370 -1 '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6',20371 -1 ],20372 -1 [20373 -1 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',20374 -1 '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f',20375 -1 ],20376 -1 [20377 -1 '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',20378 -1 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01',20379 -1 ],20380 -1 [20381 -1 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',20382 -1 '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3',20383 -1 ],20384 -1 [20385 -1 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',20386 -1 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f',20387 -1 ],20388 -1 [20389 -1 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',20390 -1 '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7',20391 -1 ],20392 -1 [20393 -1 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',20394 -1 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78',20395 -1 ],20396 -1 [20397 -1 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',20398 -1 '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1',20399 -1 ],20400 -1 [20401 -1 '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',20402 -1 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150',20403 -1 ],20404 -1 [20405 -1 '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',20406 -1 '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82',20407 -1 ],20408 -1 [20409 -1 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',20410 -1 '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc',20411 -1 ],20412 -1 [20413 -1 '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',20414 -1 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b',20415 -1 ],20416 -1 [20417 -1 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',20418 -1 '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51',20419 -1 ],20420 -1 [20421 -1 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',20422 -1 '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45',20423 -1 ],20424 -1 [20425 -1 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',20426 -1 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120',20427 -1 ],20428 -1 [20429 -1 '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',20430 -1 '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84',20431 -1 ],20432 -1 [20433 -1 '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',20434 -1 '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d',20435 -1 ],20436 -1 [20437 -1 '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',20438 -1 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d',20439 -1 ],20440 -1 [20441 -1 '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',20442 -1 '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8',20443 -1 ],20444 -1 [20445 -1 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',20446 -1 '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8',20447 -1 ],20448 -1 [20449 -1 '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',20450 -1 '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac',20451 -1 ],20452 -1 [20453 -1 '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',20454 -1 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f',20455 -1 ],20456 -1 [20457 -1 '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',20458 -1 '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962',20459 -1 ],20460 -1 [20461 -1 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',20462 -1 '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907',20463 -1 ],20464 -1 [20465 -1 '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',20466 -1 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec',20467 -1 ],20468 -1 [20469 -1 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',20470 -1 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d',20471 -1 ],20472 -1 [20473 -1 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',20474 -1 '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414',20475 -1 ],20476 -1 [20477 -1 '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',20478 -1 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd',20479 -1 ],20480 -1 [20481 -1 '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',20482 -1 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0',20483 -1 ],20484 -1 [20485 -1 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',20486 -1 '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811',20487 -1 ],20488 -1 [20489 -1 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',20490 -1 '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1',20491 -1 ],20492 -1 [20493 -1 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',20494 -1 '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c',20495 -1 ],20496 -1 [20497 -1 '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',20498 -1 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73',20499 -1 ],20500 -1 [20501 -1 '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',20502 -1 '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd',20503 -1 ],20504 -1 [20505 -1 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',20506 -1 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405',20507 -1 ],20508 -1 [20509 -1 '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',20510 -1 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589',20511 -1 ],20512 -1 [20513 -1 '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',20514 -1 '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e',20515 -1 ],20516 -1 [20517 -1 '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',20518 -1 '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27',20519 -1 ],20520 -1 [20521 -1 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',20522 -1 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1',20523 -1 ],20524 -1 [20525 -1 '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',20526 -1 '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482',20527 -1 ],20528 -1 [20529 -1 '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',20530 -1 '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945',20531 -1 ],20532 -1 [20533 -1 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',20534 -1 '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573',20535 -1 ],20536 -1 [20537 -1 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',20538 -1 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82',20539 -1 ],20540 -1 ],20541 -1 },20542 -1 naf: {20543 -1 wnd: 7,20544 -1 points: [20545 -1 [20546 -1 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',20547 -1 '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672',20548 -1 ],20549 -1 [20550 -1 '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',20551 -1 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6',20552 -1 ],20553 -1 [20554 -1 '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',20555 -1 '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da',20556 -1 ],20557 -1 [20558 -1 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',20559 -1 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37',20560 -1 ],20561 -1 [20562 -1 '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',20563 -1 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b',20564 -1 ],20565 -1 [20566 -1 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',20567 -1 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81',20568 -1 ],20569 -1 [20570 -1 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',20571 -1 '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58',20572 -1 ],20573 -1 [20574 -1 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',20575 -1 '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77',20576 -1 ],20577 -1 [20578 -1 '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',20579 -1 '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a',20580 -1 ],20581 -1 [20582 -1 '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',20583 -1 '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c',20584 -1 ],20585 -1 [20586 -1 '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',20587 -1 '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67',20588 -1 ],20589 -1 [20590 -1 '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',20591 -1 '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402',20592 -1 ],20593 -1 [20594 -1 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',20595 -1 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55',20596 -1 ],20597 -1 [20598 -1 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',20599 -1 '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482',20600 -1 ],20601 -1 [20602 -1 '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',20603 -1 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82',20604 -1 ],20605 -1 [20606 -1 '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',20607 -1 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396',20608 -1 ],20609 -1 [20610 -1 '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',20611 -1 '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49',20612 -1 ],20613 -1 [20614 -1 '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',20615 -1 '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf',20616 -1 ],20617 -1 [20618 -1 '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',20619 -1 '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a',20620 -1 ],20621 -1 [20622 -1 '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',20623 -1 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7',20624 -1 ],20625 -1 [20626 -1 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',20627 -1 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933',20628 -1 ],20629 -1 [20630 -1 '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',20631 -1 '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a',20632 -1 ],20633 -1 [20634 -1 '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',20635 -1 '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6',20636 -1 ],20637 -1 [20638 -1 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',20639 -1 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37',20640 -1 ],20641 -1 [20642 -1 '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',20643 -1 '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e',20644 -1 ],20645 -1 [20646 -1 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',20647 -1 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6',20648 -1 ],20649 -1 [20650 -1 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',20651 -1 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476',20652 -1 ],20653 -1 [20654 -1 '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',20655 -1 '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40',20656 -1 ],20657 -1 [20658 -1 '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',20659 -1 '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61',20660 -1 ],20661 -1 [20662 -1 '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',20663 -1 '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683',20664 -1 ],20665 -1 [20666 -1 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',20667 -1 '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5',20668 -1 ],20669 -1 [20670 -1 '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',20671 -1 '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b',20672 -1 ],20673 -1 [20674 -1 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',20675 -1 '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417',20676 -1 ],20677 -1 [20678 -1 '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',20679 -1 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868',20680 -1 ],20681 -1 [20682 -1 '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',20683 -1 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a',20684 -1 ],20685 -1 [20686 -1 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',20687 -1 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6',20688 -1 ],20689 -1 [20690 -1 '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',20691 -1 '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996',20692 -1 ],20693 -1 [20694 -1 '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',20695 -1 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e',20696 -1 ],20697 -1 [20698 -1 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',20699 -1 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d',20700 -1 ],20701 -1 [20702 -1 '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',20703 -1 '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2',20704 -1 ],20705 -1 [20706 -1 '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',20707 -1 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e',20708 -1 ],20709 -1 [20710 -1 '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',20711 -1 '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437',20712 -1 ],20713 -1 [20714 -1 '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',20715 -1 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311',20716 -1 ],20717 -1 [20718 -1 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',20719 -1 '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4',20720 -1 ],20721 -1 [20722 -1 '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',20723 -1 '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575',20724 -1 ],20725 -1 [20726 -1 '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',20727 -1 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d',20728 -1 ],20729 -1 [20730 -1 '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',20731 -1 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d',20732 -1 ],20733 -1 [20734 -1 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',20735 -1 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629',20736 -1 ],20737 -1 [20738 -1 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',20739 -1 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06',20740 -1 ],20741 -1 [20742 -1 '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',20743 -1 '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374',20744 -1 ],20745 -1 [20746 -1 '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',20747 -1 '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee',20748 -1 ],20749 -1 [20750 -1 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',20751 -1 '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1',20752 -1 ],20753 -1 [20754 -1 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',20755 -1 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b',20756 -1 ],20757 -1 [20758 -1 '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',20759 -1 '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661',20760 -1 ],20761 -1 [20762 -1 '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',20763 -1 '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6',20764 -1 ],20765 -1 [20766 -1 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',20767 -1 '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e',20768 -1 ],20769 -1 [20770 -1 '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',20771 -1 '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d',20772 -1 ],20773 -1 [20774 -1 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',20775 -1 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc',20776 -1 ],20777 -1 [20778 -1 '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',20779 -1 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4',20780 -1 ],20781 -1 [20782 -1 '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',20783 -1 '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c',20784 -1 ],20785 -1 [20786 -1 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',20787 -1 '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b',20788 -1 ],20789 -1 [20790 -1 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',20791 -1 '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913',20792 -1 ],20793 -1 [20794 -1 '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',20795 -1 '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154',20796 -1 ],20797 -1 [20798 -1 '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',20799 -1 '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865',20800 -1 ],20801 -1 [20802 -1 '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',20803 -1 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc',20804 -1 ],20805 -1 [20806 -1 '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',20807 -1 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224',20808 -1 ],20809 -1 [20810 -1 '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',20811 -1 '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e',20812 -1 ],20813 -1 [20814 -1 '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',20815 -1 '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6',20816 -1 ],20817 -1 [20818 -1 '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',20819 -1 '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511',20820 -1 ],20821 -1 [20822 -1 '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',20823 -1 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b',20824 -1 ],20825 -1 [20826 -1 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',20827 -1 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2',20828 -1 ],20829 -1 [20830 -1 '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',20831 -1 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c',20832 -1 ],20833 -1 [20834 -1 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',20835 -1 '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3',20836 -1 ],20837 -1 [20838 -1 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',20839 -1 '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d',20840 -1 ],20841 -1 [20842 -1 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',20843 -1 '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700',20844 -1 ],20845 -1 [20846 -1 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',20847 -1 '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4',20848 -1 ],20849 -1 [20850 -1 '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',20851 -1 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196',20852 -1 ],20853 -1 [20854 -1 '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',20855 -1 '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4',20856 -1 ],20857 -1 [20858 -1 '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',20859 -1 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257',20860 -1 ],20861 -1 [20862 -1 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',20863 -1 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13',20864 -1 ],20865 -1 [20866 -1 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',20867 -1 '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096',20868 -1 ],20869 -1 [20870 -1 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',20871 -1 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38',20872 -1 ],20873 -1 [20874 -1 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',20875 -1 '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f',20876 -1 ],20877 -1 [20878 -1 '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',20879 -1 '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448',20880 -1 ],20881 -1 [20882 -1 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',20883 -1 '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a',20884 -1 ],20885 -1 [20886 -1 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',20887 -1 '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4',20888 -1 ],20889 -1 [20890 -1 '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',20891 -1 '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437',20892 -1 ],20893 -1 [20894 -1 '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',20895 -1 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7',20896 -1 ],20897 -1 [20898 -1 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',20899 -1 '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d',20900 -1 ],20901 -1 [20902 -1 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',20903 -1 '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a',20904 -1 ],20905 -1 [20906 -1 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',20907 -1 '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54',20908 -1 ],20909 -1 [20910 -1 '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',20911 -1 '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77',20912 -1 ],20913 -1 [20914 -1 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',20915 -1 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517',20916 -1 ],20917 -1 [20918 -1 '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',20919 -1 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10',20920 -1 ],20921 -1 [20922 -1 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',20923 -1 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125',20924 -1 ],20925 -1 [20926 -1 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',20927 -1 '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e',20928 -1 ],20929 -1 [20930 -1 '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',20931 -1 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1',20932 -1 ],20933 -1 [20934 -1 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',20935 -1 '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2',20936 -1 ],20937 -1 [20938 -1 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',20939 -1 '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423',20940 -1 ],20941 -1 [20942 -1 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',20943 -1 '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8',20944 -1 ],20945 -1 [20946 -1 '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',20947 -1 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758',20948 -1 ],20949 -1 [20950 -1 '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',20951 -1 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375',20952 -1 ],20953 -1 [20954 -1 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',20955 -1 '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d',20956 -1 ],20957 -1 [20958 -1 '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',20959 -1 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec',20960 -1 ],20961 -1 [20962 -1 '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',20963 -1 '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0',20964 -1 ],20965 -1 [20966 -1 '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',20967 -1 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c',20968 -1 ],20969 -1 [20970 -1 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',20971 -1 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4',20972 -1 ],20973 -1 [20974 -1 '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',20975 -1 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f',20976 -1 ],20977 -1 [20978 -1 '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',20979 -1 '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649',20980 -1 ],20981 -1 [20982 -1 '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',20983 -1 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826',20984 -1 ],20985 -1 [20986 -1 '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',20987 -1 '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5',20988 -1 ],20989 -1 [20990 -1 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',20991 -1 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87',20992 -1 ],20993 -1 [20994 -1 '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',20995 -1 '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b',20996 -1 ],20997 -1 [20998 -1 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',20999 -1 '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc',21000 -1 ],21001 -1 [21002 -1 '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',21003 -1 '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c',21004 -1 ],21005 -1 [21006 -1 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',21007 -1 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f',21008 -1 ],21009 -1 [21010 -1 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',21011 -1 '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a',21012 -1 ],21013 -1 [21014 -1 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',21015 -1 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46',21016 -1 ],21017 -1 [21018 -1 '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',21019 -1 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f',21020 -1 ],21021 -1 [21022 -1 '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',21023 -1 '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03',21024 -1 ],21025 -1 [21026 -1 '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',21027 -1 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08',21028 -1 ],21029 -1 [21030 -1 '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',21031 -1 '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8',21032 -1 ],21033 -1 [21034 -1 '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',21035 -1 '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373',21036 -1 ],21037 -1 [21038 -1 '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',21039 -1 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3',21040 -1 ],21041 -1 [21042 -1 '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',21043 -1 '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8',21044 -1 ],21045 -1 [21046 -1 '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',21047 -1 '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1',21048 -1 ],21049 -1 [21050 -1 '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',21051 -1 '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9',21052 -1 ],21053 -1 ],21054 -1 },21055 -1 };21056 -121057 -1 },{}],97:[function(require,module,exports){21058 -1 'use strict';21059 -121060 -1 var utils = exports;21061 -1 var BN = require('bn.js');21062 -1 var minAssert = require('minimalistic-assert');21063 -1 var minUtils = require('minimalistic-crypto-utils');21064 -121065 -1 utils.assert = minAssert;21066 -1 utils.toArray = minUtils.toArray;21067 -1 utils.zero2 = minUtils.zero2;21068 -1 utils.toHex = minUtils.toHex;21069 -1 utils.encode = minUtils.encode;21070 -121071 -1 // Represent num in a w-NAF form21072 -1 function getNAF(num, w, bits) {21073 -1 var naf = new Array(Math.max(num.bitLength(), bits) + 1);21074 -1 naf.fill(0);21075 -121076 -1 var ws = 1 << (w + 1);21077 -1 var k = num.clone();21078 -121079 -1 for (var i = 0; i < naf.length; i++) {21080 -1 var z;21081 -1 var mod = k.andln(ws - 1);21082 -1 if (k.isOdd()) {21083 -1 if (mod > (ws >> 1) - 1)21084 -1 z = (ws >> 1) - mod;21085 -1 else21086 -1 z = mod;21087 -1 k.isubn(z);21088 -1 } else {21089 -1 z = 0;21090 -1 }21091 -121092 -1 naf[i] = z;21093 -1 k.iushrn(1);21094 -1 }21095 -121096 -1 return naf;21097 -1 }21098 -1 utils.getNAF = getNAF;21099 -121100 -1 // Represent k1, k2 in a Joint Sparse Form21101 -1 function getJSF(k1, k2) {21102 -1 var jsf = [21103 -1 [],21104 -1 [],21105 -1 ];21106 -121107 -1 k1 = k1.clone();21108 -1 k2 = k2.clone();21109 -1 var d1 = 0;21110 -1 var d2 = 0;21111 -1 var m8;21112 -1 while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {21113 -1 // First phase21114 -1 var m14 = (k1.andln(3) + d1) & 3;21115 -1 var m24 = (k2.andln(3) + d2) & 3;21116 -1 if (m14 === 3)21117 -1 m14 = -1;21118 -1 if (m24 === 3)21119 -1 m24 = -1;21120 -1 var u1;21121 -1 if ((m14 & 1) === 0) {21122 -1 u1 = 0;21123 -1 } else {21124 -1 m8 = (k1.andln(7) + d1) & 7;21125 -1 if ((m8 === 3 || m8 === 5) && m24 === 2)21126 -1 u1 = -m14;21127 -1 else21128 -1 u1 = m14;21129 -1 }21130 -1 jsf[0].push(u1);21131 -121132 -1 var u2;21133 -1 if ((m24 & 1) === 0) {21134 -1 u2 = 0;21135 -1 } else {21136 -1 m8 = (k2.andln(7) + d2) & 7;21137 -1 if ((m8 === 3 || m8 === 5) && m14 === 2)21138 -1 u2 = -m24;21139 -1 else21140 -1 u2 = m24;21141 -1 }21142 -1 jsf[1].push(u2);21143 -121144 -1 // Second phase21145 -1 if (2 * d1 === u1 + 1)21146 -1 d1 = 1 - d1;21147 -1 if (2 * d2 === u2 + 1)21148 -1 d2 = 1 - d2;21149 -1 k1.iushrn(1);21150 -1 k2.iushrn(1);21151 -1 }21152 -121153 -1 return jsf;21154 -1 }21155 -1 utils.getJSF = getJSF;21156 -121157 -1 function cachedProperty(obj, name, computer) {21158 -1 var key = '_' + name;21159 -1 obj.prototype[name] = function cachedProperty() {21160 -1 return this[key] !== undefined ? this[key] :21161 -1 this[key] = computer.call(this);21162 -1 };21163 -1 }21164 -1 utils.cachedProperty = cachedProperty;21165 -121166 -1 function parseBytes(bytes) {21167 -1 return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :21168 -1 bytes;21169 -1 }21170 -1 utils.parseBytes = parseBytes;21171 -121172 -1 function intFromLE(bytes) {21173 -1 return new BN(bytes, 'hex', 'le');21174 -1 }21175 -1 utils.intFromLE = intFromLE;21176 -121177 -121178 -1 },{"bn.js":98,"minimalistic-assert":136,"minimalistic-crypto-utils":137}],98:[function(require,module,exports){21179 -1 arguments[4][15][0].apply(exports,arguments)21180 -1 },{"buffer":19,"dup":15}],99:[function(require,module,exports){21181 -1 module.exports={21182 -1 "name": "elliptic",21183 -1 "version": "6.5.4",21184 -1 "description": "EC cryptography",21185 -1 "main": "lib/elliptic.js",21186 -1 "files": [21187 -1 "lib"21188 -1 ],21189 -1 "scripts": {21190 -1 "lint": "eslint lib test",21191 -1 "lint:fix": "npm run lint -- --fix",21192 -1 "unit": "istanbul test _mocha --reporter=spec test/index.js",21193 -1 "test": "npm run lint && npm run unit",21194 -1 "version": "grunt dist && git add dist/"21195 -1 },21196 -1 "repository": {21197 -1 "type": "git",21198 -1 "url": "git@github.com:indutny/elliptic"21199 -1 },21200 -1 "keywords": [21201 -1 "EC",21202 -1 "Elliptic",21203 -1 "curve",21204 -1 "Cryptography"21205 -1 ],21206 -1 "author": "Fedor Indutny <fedor@indutny.com>",21207 -1 "license": "MIT",21208 -1 "bugs": {21209 -1 "url": "https://github.com/indutny/elliptic/issues"21210 -1 },21211 -1 "homepage": "https://github.com/indutny/elliptic",21212 -1 "devDependencies": {21213 -1 "brfs": "^2.0.2",21214 -1 "coveralls": "^3.1.0",21215 -1 "eslint": "^7.6.0",21216 -1 "grunt": "^1.2.1",21217 -1 "grunt-browserify": "^5.3.0",21218 -1 "grunt-cli": "^1.3.2",21219 -1 "grunt-contrib-connect": "^3.0.0",21220 -1 "grunt-contrib-copy": "^1.0.0",21221 -1 "grunt-contrib-uglify": "^5.0.0",21222 -1 "grunt-mocha-istanbul": "^5.0.2",21223 -1 "grunt-saucelabs": "^9.0.1",21224 -1 "istanbul": "^0.4.5",21225 -1 "mocha": "^8.0.1"21226 -1 },21227 -1 "dependencies": {21228 -1 "bn.js": "^4.11.9",21229 -1 "brorand": "^1.1.0",21230 -1 "hash.js": "^1.0.0",21231 -1 "hmac-drbg": "^1.0.1",21232 -1 "inherits": "^2.0.4",21233 -1 "minimalistic-assert": "^1.0.1",21234 -1 "minimalistic-crypto-utils": "^1.0.1"21235 -1 }21236 -1 }21237 -121238 -1 },{}],100:[function(require,module,exports){21239 -1 // Copyright Joyent, Inc. and other Node contributors.21240 -1 //21241 -1 // Permission is hereby granted, free of charge, to any person obtaining a21242 -1 // copy of this software and associated documentation files (the21243 -1 // "Software"), to deal in the Software without restriction, including21244 -1 // without limitation the rights to use, copy, modify, merge, publish,21245 -1 // distribute, sublicense, and/or sell copies of the Software, and to permit21246 -1 // persons to whom the Software is furnished to do so, subject to the21247 -1 // following conditions:21248 -1 //21249 -1 // The above copyright notice and this permission notice shall be included21250 -1 // in all copies or substantial portions of the Software.21251 -1 //21252 -1 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS21253 -1 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF21254 -1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN21255 -1 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,21256 -1 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR21257 -1 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE21258 -1 // USE OR OTHER DEALINGS IN THE SOFTWARE.21259 -121260 -1 'use strict';21261 -121262 -1 var R = typeof Reflect === 'object' ? Reflect : null21263 -1 var ReflectApply = R && typeof R.apply === 'function'21264 -1 ? R.apply21265 -1 : function ReflectApply(target, receiver, args) {21266 -1 return Function.prototype.apply.call(target, receiver, args);21267 -1 }21268 -121269 -1 var ReflectOwnKeys21270 -1 if (R && typeof R.ownKeys === 'function') {21271 -1 ReflectOwnKeys = R.ownKeys21272 -1 } else if (Object.getOwnPropertySymbols) {21273 -1 ReflectOwnKeys = function ReflectOwnKeys(target) {21274 -1 return Object.getOwnPropertyNames(target)21275 -1 .concat(Object.getOwnPropertySymbols(target));21276 -1 };21277 -1 } else {21278 -1 ReflectOwnKeys = function ReflectOwnKeys(target) {21279 -1 return Object.getOwnPropertyNames(target);21280 -1 };21281 -1 }21282 -121283 -1 function ProcessEmitWarning(warning) {21284 -1 if (console && console.warn) console.warn(warning);21285 -1 }21286 -121287 -1 var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {21288 -1 return value !== value;21289 -1 }21290 -121291 -1 function EventEmitter() {21292 -1 EventEmitter.init.call(this);21293 -1 }21294 -1 module.exports = EventEmitter;21295 -1 module.exports.once = once;21296 -121297 -1 // Backwards-compat with node 0.10.x21298 -1 EventEmitter.EventEmitter = EventEmitter;21299 -121300 -1 EventEmitter.prototype._events = undefined;21301 -1 EventEmitter.prototype._eventsCount = 0;21302 -1 EventEmitter.prototype._maxListeners = undefined;21303 -121304 -1 // By default EventEmitters will print a warning if more than 10 listeners are21305 -1 // added to it. This is a useful default which helps finding memory leaks.21306 -1 var defaultMaxListeners = 10;21307 -121308 -1 function checkListener(listener) {21309 -1 if (typeof listener !== 'function') {21310 -1 throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);21311 -1 }21312 -1 }21313 -121314 -1 Object.defineProperty(EventEmitter, 'defaultMaxListeners', {21315 -1 enumerable: true,21316 -1 get: function() {21317 -1 return defaultMaxListeners;21318 -1 },21319 -1 set: function(arg) {21320 -1 if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {21321 -1 throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');21322 -1 }21323 -1 defaultMaxListeners = arg;21324 -1 }21325 -1 });21326 -121327 -1 EventEmitter.init = function() {21328 -121329 -1 if (this._events === undefined ||21330 -1 this._events === Object.getPrototypeOf(this)._events) {21331 -1 this._events = Object.create(null);21332 -1 this._eventsCount = 0;21333 -1 }21334 -121335 -1 this._maxListeners = this._maxListeners || undefined;21336 -1 };21337 -121338 -1 // Obviously not all Emitters should be limited to 10. This function allows21339 -1 // that to be increased. Set to zero for unlimited.21340 -1 EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {21341 -1 if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {21342 -1 throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');21343 -1 }21344 -1 this._maxListeners = n;21345 -1 return this;21346 -1 };21347 -121348 -1 function _getMaxListeners(that) {21349 -1 if (that._maxListeners === undefined)21350 -1 return EventEmitter.defaultMaxListeners;21351 -1 return that._maxListeners;21352 -1 }21353 -121354 -1 EventEmitter.prototype.getMaxListeners = function getMaxListeners() {21355 -1 return _getMaxListeners(this);21356 -1 };21357 -121358 -1 EventEmitter.prototype.emit = function emit(type) {21359 -1 var args = [];21360 -1 for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);21361 -1 var doError = (type === 'error');21362 -121363 -1 var events = this._events;21364 -1 if (events !== undefined)21365 -1 doError = (doError && events.error === undefined);21366 -1 else if (!doError)21367 -1 return false;21368 -121369 -1 // If there is no 'error' event listener then throw.21370 -1 if (doError) {21371 -1 var er;21372 -1 if (args.length > 0)21373 -1 er = args[0];21374 -1 if (er instanceof Error) {21375 -1 // Note: The comments on the `throw` lines are intentional, they show21376 -1 // up in Node's output if this results in an unhandled exception.21377 -1 throw er; // Unhandled 'error' event21378 -1 }21379 -1 // At least give some kind of context to the user21380 -1 var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));21381 -1 err.context = er;21382 -1 throw err; // Unhandled 'error' event21383 -1 }21384 -121385 -1 var handler = events[type];21386 -121387 -1 if (handler === undefined)21388 -1 return false;21389 -121390 -1 if (typeof handler === 'function') {21391 -1 ReflectApply(handler, this, args);21392 -1 } else {21393 -1 var len = handler.length;21394 -1 var listeners = arrayClone(handler, len);21395 -1 for (var i = 0; i < len; ++i)21396 -1 ReflectApply(listeners[i], this, args);21397 -1 }21398 -121399 -1 return true;21400 -1 };21401 -121402 -1 function _addListener(target, type, listener, prepend) {21403 -1 var m;21404 -1 var events;21405 -1 var existing;21406 -121407 -1 checkListener(listener);21408 -121409 -1 events = target._events;21410 -1 if (events === undefined) {21411 -1 events = target._events = Object.create(null);21412 -1 target._eventsCount = 0;21413 -1 } else {21414 -1 // To avoid recursion in the case that type === "newListener"! Before21415 -1 // adding it to the listeners, first emit "newListener".21416 -1 if (events.newListener !== undefined) {21417 -1 target.emit('newListener', type,21418 -1 listener.listener ? listener.listener : listener);21419 -121420 -1 // Re-assign `events` because a newListener handler could have caused the21421 -1 // this._events to be assigned to a new object21422 -1 events = target._events;21423 -1 }21424 -1 existing = events[type];21425 -1 }21426 -121427 -1 if (existing === undefined) {21428 -1 // Optimize the case of one listener. Don't need the extra array object.21429 -1 existing = events[type] = listener;21430 -1 ++target._eventsCount;21431 -1 } else {21432 -1 if (typeof existing === 'function') {21433 -1 // Adding the second element, need to change to array.21434 -1 existing = events[type] =21435 -1 prepend ? [listener, existing] : [existing, listener];21436 -1 // If we've already got an array, just append.21437 -1 } else if (prepend) {21438 -1 existing.unshift(listener);21439 -1 } else {21440 -1 existing.push(listener);21441 -1 }21442 -121443 -1 // Check for listener leak21444 -1 m = _getMaxListeners(target);21445 -1 if (m > 0 && existing.length > m && !existing.warned) {21446 -1 existing.warned = true;21447 -1 // No error code for this since it is a Warning21448 -1 // eslint-disable-next-line no-restricted-syntax21449 -1 var w = new Error('Possible EventEmitter memory leak detected. ' +21450 -1 existing.length + ' ' + String(type) + ' listeners ' +21451 -1 'added. Use emitter.setMaxListeners() to ' +21452 -1 'increase limit');21453 -1 w.name = 'MaxListenersExceededWarning';21454 -1 w.emitter = target;21455 -1 w.type = type;21456 -1 w.count = existing.length;21457 -1 ProcessEmitWarning(w);21458 -1 }21459 -1 }21460 -121461 -1 return target;21462 -1 }21463 -121464 -1 EventEmitter.prototype.addListener = function addListener(type, listener) {21465 -1 return _addListener(this, type, listener, false);21466 -1 };21467 -121468 -1 EventEmitter.prototype.on = EventEmitter.prototype.addListener;21469 -121470 -1 EventEmitter.prototype.prependListener =21471 -1 function prependListener(type, listener) {21472 -1 return _addListener(this, type, listener, true);21473 -1 };21474 -121475 -1 function onceWrapper() {21476 -1 if (!this.fired) {21477 -1 this.target.removeListener(this.type, this.wrapFn);21478 -1 this.fired = true;21479 -1 if (arguments.length === 0)21480 -1 return this.listener.call(this.target);21481 -1 return this.listener.apply(this.target, arguments);21482 -1 }21483 -1 }21484 -121485 -1 function _onceWrap(target, type, listener) {21486 -1 var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };21487 -1 var wrapped = onceWrapper.bind(state);21488 -1 wrapped.listener = listener;21489 -1 state.wrapFn = wrapped;21490 -1 return wrapped;21491 -1 }21492 -121493 -1 EventEmitter.prototype.once = function once(type, listener) {21494 -1 checkListener(listener);21495 -1 this.on(type, _onceWrap(this, type, listener));21496 -1 return this;21497 -1 };21498 -121499 -1 EventEmitter.prototype.prependOnceListener =21500 -1 function prependOnceListener(type, listener) {21501 -1 checkListener(listener);21502 -1 this.prependListener(type, _onceWrap(this, type, listener));21503 -1 return this;21504 -1 };21505 -121506 -1 // Emits a 'removeListener' event if and only if the listener was removed.21507 -1 EventEmitter.prototype.removeListener =21508 -1 function removeListener(type, listener) {21509 -1 var list, events, position, i, originalListener;21510 -121511 -1 checkListener(listener);21512 -121513 -1 events = this._events;21514 -1 if (events === undefined)21515 -1 return this;21516 -121517 -1 list = events[type];21518 -1 if (list === undefined)21519 -1 return this;21520 -121521 -1 if (list === listener || list.listener === listener) {21522 -1 if (--this._eventsCount === 0)21523 -1 this._events = Object.create(null);21524 -1 else {21525 -1 delete events[type];21526 -1 if (events.removeListener)21527 -1 this.emit('removeListener', type, list.listener || listener);21528 -1 }21529 -1 } else if (typeof list !== 'function') {21530 -1 position = -1;21531 -121532 -1 for (i = list.length - 1; i >= 0; i--) {21533 -1 if (list[i] === listener || list[i].listener === listener) {21534 -1 originalListener = list[i].listener;21535 -1 position = i;21536 -1 break;21537 -1 }21538 -1 }21539 -121540 -1 if (position < 0)21541 -1 return this;21542 -121543 -1 if (position === 0)21544 -1 list.shift();21545 -1 else {21546 -1 spliceOne(list, position);21547 -1 }21548 -121549 -1 if (list.length === 1)21550 -1 events[type] = list[0];21551 -121552 -1 if (events.removeListener !== undefined)21553 -1 this.emit('removeListener', type, originalListener || listener);21554 -1 }21555 -121556 -1 return this;21557 -1 };21558 -121559 -1 EventEmitter.prototype.off = EventEmitter.prototype.removeListener;21560 -121561 -1 EventEmitter.prototype.removeAllListeners =21562 -1 function removeAllListeners(type) {21563 -1 var listeners, events, i;21564 -121565 -1 events = this._events;21566 -1 if (events === undefined)21567 -1 return this;21568 -121569 -1 // not listening for removeListener, no need to emit21570 -1 if (events.removeListener === undefined) {21571 -1 if (arguments.length === 0) {21572 -1 this._events = Object.create(null);21573 -1 this._eventsCount = 0;21574 -1 } else if (events[type] !== undefined) {21575 -1 if (--this._eventsCount === 0)21576 -1 this._events = Object.create(null);21577 -1 else21578 -1 delete events[type];21579 -1 }21580 -1 return this;21581 -1 }21582 -121583 -1 // emit removeListener for all listeners on all events21584 -1 if (arguments.length === 0) {21585 -1 var keys = Object.keys(events);21586 -1 var key;21587 -1 for (i = 0; i < keys.length; ++i) {21588 -1 key = keys[i];21589 -1 if (key === 'removeListener') continue;21590 -1 this.removeAllListeners(key);21591 -1 }21592 -1 this.removeAllListeners('removeListener');21593 -1 this._events = Object.create(null);21594 -1 this._eventsCount = 0;21595 -1 return this;21596 -1 }21597 -121598 -1 listeners = events[type];21599 -121600 -1 if (typeof listeners === 'function') {21601 -1 this.removeListener(type, listeners);21602 -1 } else if (listeners !== undefined) {21603 -1 // LIFO order21604 -1 for (i = listeners.length - 1; i >= 0; i--) {21605 -1 this.removeListener(type, listeners[i]);21606 -1 }21607 -1 }21608 -121609 -1 return this;21610 -1 };21611 -121612 -1 function _listeners(target, type, unwrap) {21613 -1 var events = target._events;21614 -121615 -1 if (events === undefined)21616 -1 return [];21617 -121618 -1 var evlistener = events[type];21619 -1 if (evlistener === undefined)21620 -1 return [];21621 -121622 -1 if (typeof evlistener === 'function')21623 -1 return unwrap ? [evlistener.listener || evlistener] : [evlistener];21624 -121625 -1 return unwrap ?21626 -1 unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);21627 -1 }21628 -121629 -1 EventEmitter.prototype.listeners = function listeners(type) {21630 -1 return _listeners(this, type, true);21631 -1 };21632 -121633 -1 EventEmitter.prototype.rawListeners = function rawListeners(type) {21634 -1 return _listeners(this, type, false);21635 -1 };21636 -121637 -1 EventEmitter.listenerCount = function(emitter, type) {21638 -1 if (typeof emitter.listenerCount === 'function') {21639 -1 return emitter.listenerCount(type);21640 -1 } else {21641 -1 return listenerCount.call(emitter, type);21642 -1 }21643 -1 };21644 -121645 -1 EventEmitter.prototype.listenerCount = listenerCount;21646 -1 function listenerCount(type) {21647 -1 var events = this._events;21648 -121649 -1 if (events !== undefined) {21650 -1 var evlistener = events[type];21651 -121652 -1 if (typeof evlistener === 'function') {21653 -1 return 1;21654 -1 } else if (evlistener !== undefined) {21655 -1 return evlistener.length;21656 -1 }21657 -1 }21658 -121659 -1 return 0;21660 -1 }21661 -121662 -1 EventEmitter.prototype.eventNames = function eventNames() {21663 -1 return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];21664 -1 };21665 -121666 -1 function arrayClone(arr, n) {21667 -1 var copy = new Array(n);21668 -1 for (var i = 0; i < n; ++i)21669 -1 copy[i] = arr[i];21670 -1 return copy;21671 -1 }21672 -121673 -1 function spliceOne(list, index) {21674 -1 for (; index + 1 < list.length; index++)21675 -1 list[index] = list[index + 1];21676 -1 list.pop();21677 -1 }21678 -121679 -1 function unwrapListeners(arr) {21680 -1 var ret = new Array(arr.length);21681 -1 for (var i = 0; i < ret.length; ++i) {21682 -1 ret[i] = arr[i].listener || arr[i];21683 -1 }21684 -1 return ret;21685 -1 }21686 -121687 -1 function once(emitter, name) {21688 -1 return new Promise(function (resolve, reject) {21689 -1 function eventListener() {21690 -1 if (errorListener !== undefined) {21691 -1 emitter.removeListener('error', errorListener);21692 -1 }21693 -1 resolve([].slice.call(arguments));21694 -1 };21695 -1 var errorListener;21696 -121697 -1 // Adding an error listener is not optional because21698 -1 // if an error is thrown on an event emitter we cannot21699 -1 // guarantee that the actual event we are waiting will21700 -1 // be fired. The result could be a silent way to create21701 -1 // memory or file descriptor leaks, which is something21702 -1 // we should avoid.21703 -1 if (name !== 'error') {21704 -1 errorListener = function errorListener(err) {21705 -1 emitter.removeListener(name, eventListener);21706 -1 reject(err);21707 -1 };21708 -121709 -1 emitter.once('error', errorListener);21710 -1 }21711 -121712 -1 emitter.once(name, eventListener);21713 -1 });21714 -1 }21715 -121716 -1 },{}],101:[function(require,module,exports){21717 -1 var Buffer = require('safe-buffer').Buffer21718 -1 var MD5 = require('md5.js')21719 -121720 -1 /* eslint-disable camelcase */21721 -1 function EVP_BytesToKey (password, salt, keyBits, ivLen) {21722 -1 if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary')21723 -1 if (salt) {21724 -1 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary')21725 -1 if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length')21726 -1 }21727 -121728 -1 var keyLen = keyBits / 821729 -1 var key = Buffer.alloc(keyLen)21730 -1 var iv = Buffer.alloc(ivLen || 0)21731 -1 var tmp = Buffer.alloc(0)21732 -121733 -1 while (keyLen > 0 || ivLen > 0) {21734 -1 var hash = new MD5()21735 -1 hash.update(tmp)21736 -1 hash.update(password)21737 -1 if (salt) hash.update(salt)21738 -1 tmp = hash.digest()21739 -121740 -1 var used = 021741 -121742 -1 if (keyLen > 0) {21743 -1 var keyStart = key.length - keyLen21744 -1 used = Math.min(keyLen, tmp.length)21745 -1 tmp.copy(key, keyStart, 0, used)21746 -1 keyLen -= used21747 -1 }21748 -121749 -1 if (used < tmp.length && ivLen > 0) {21750 -1 var ivStart = iv.length - ivLen21751 -1 var length = Math.min(ivLen, tmp.length - used)21752 -1 tmp.copy(iv, ivStart, used, used + length)21753 -1 ivLen -= length21754 -1 }21755 -1 }21756 -121757 -1 tmp.fill(0)21758 -1 return { key: key, iv: iv }21759 -1 }21760 -121761 -1 module.exports = EVP_BytesToKey21762 -121763 -1 },{"md5.js":133,"safe-buffer":160}],102:[function(require,module,exports){21764 -1 'use strict'21765 -1 var Buffer = require('safe-buffer').Buffer21766 -1 var Transform = require('readable-stream').Transform21767 -1 var inherits = require('inherits')21768 -121769 -1 function throwIfNotStringOrBuffer (val, prefix) {21770 -1 if (!Buffer.isBuffer(val) && typeof val !== 'string') {21771 -1 throw new TypeError(prefix + ' must be a string or a buffer')21772 -1 }21773 -1 }21774 -121775 -1 function HashBase (blockSize) {21776 -1 Transform.call(this)21777 -121778 -1 this._block = Buffer.allocUnsafe(blockSize)21779 -1 this._blockSize = blockSize21780 -1 this._blockOffset = 021781 -1 this._length = [0, 0, 0, 0]21782 -121783 -1 this._finalized = false21784 -1 }21785 -121786 -1 inherits(HashBase, Transform)21787 -121788 -1 HashBase.prototype._transform = function (chunk, encoding, callback) {21789 -1 var error = null21790 -1 try {21791 -1 this.update(chunk, encoding)21792 -1 } catch (err) {21793 -1 error = err21794 -1 }21795 -121796 -1 callback(error)21797 -1 }21798 -121799 -1 HashBase.prototype._flush = function (callback) {21800 -1 var error = null21801 -1 try {21802 -1 this.push(this.digest())21803 -1 } catch (err) {21804 -1 error = err21805 -1 }21806 -121807 -1 callback(error)21808 -1 }21809 -121810 -1 HashBase.prototype.update = function (data, encoding) {21811 -1 throwIfNotStringOrBuffer(data, 'Data')21812 -1 if (this._finalized) throw new Error('Digest already called')21813 -1 if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)21814 -121815 -1 // consume data21816 -1 var block = this._block21817 -1 var offset = 021818 -1 while (this._blockOffset + data.length - offset >= this._blockSize) {21819 -1 for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]21820 -1 this._update()21821 -1 this._blockOffset = 021822 -1 }21823 -1 while (offset < data.length) block[this._blockOffset++] = data[offset++]21824 -121825 -1 // update length21826 -1 for (var j = 0, carry = data.length * 8; carry > 0; ++j) {21827 -1 this._length[j] += carry21828 -1 carry = (this._length[j] / 0x0100000000) | 021829 -1 if (carry > 0) this._length[j] -= 0x0100000000 * carry21830 -1 }21831 -121832 -1 return this21833 -1 }21834 -121835 -1 HashBase.prototype._update = function () {21836 -1 throw new Error('_update is not implemented')21837 -1 }21838 -121839 -1 HashBase.prototype.digest = function (encoding) {21840 -1 if (this._finalized) throw new Error('Digest already called')21841 -1 this._finalized = true21842 -121843 -1 var digest = this._digest()21844 -1 if (encoding !== undefined) digest = digest.toString(encoding)21845 -121846 -1 // reset state21847 -1 this._block.fill(0)21848 -1 this._blockOffset = 021849 -1 for (var i = 0; i < 4; ++i) this._length[i] = 021850 -121851 -1 return digest21852 -1 }21853 -121854 -1 HashBase.prototype._digest = function () {21855 -1 throw new Error('_digest is not implemented')21856 -1 }21857 -121858 -1 module.exports = HashBase21859 -121860 -1 },{"inherits":132,"readable-stream":117,"safe-buffer":160}],103:[function(require,module,exports){21861 -1 arguments[4][47][0].apply(exports,arguments)21862 -1 },{"dup":47}],104:[function(require,module,exports){21863 -1 arguments[4][48][0].apply(exports,arguments)21864 -1 },{"./_stream_readable":106,"./_stream_writable":108,"_process":149,"dup":48,"inherits":132}],105:[function(require,module,exports){21865 -1 arguments[4][49][0].apply(exports,arguments)21866 -1 },{"./_stream_transform":107,"dup":49,"inherits":132}],106:[function(require,module,exports){21867 -1 arguments[4][50][0].apply(exports,arguments)21868 -1 },{"../errors":103,"./_stream_duplex":104,"./internal/streams/async_iterator":109,"./internal/streams/buffer_list":110,"./internal/streams/destroy":111,"./internal/streams/from":113,"./internal/streams/state":115,"./internal/streams/stream":116,"_process":149,"buffer":63,"dup":50,"events":100,"inherits":132,"string_decoder/":185,"util":19}],107:[function(require,module,exports){21869 -1 arguments[4][51][0].apply(exports,arguments)21870 -1 },{"../errors":103,"./_stream_duplex":104,"dup":51,"inherits":132}],108:[function(require,module,exports){21871 -1 arguments[4][52][0].apply(exports,arguments)21872 -1 },{"../errors":103,"./_stream_duplex":104,"./internal/streams/destroy":111,"./internal/streams/state":115,"./internal/streams/stream":116,"_process":149,"buffer":63,"dup":52,"inherits":132,"util-deprecate":187}],109:[function(require,module,exports){21873 -1 arguments[4][53][0].apply(exports,arguments)21874 -1 },{"./end-of-stream":112,"_process":149,"dup":53}],110:[function(require,module,exports){21875 -1 arguments[4][54][0].apply(exports,arguments)21876 -1 },{"buffer":63,"dup":54,"util":19}],111:[function(require,module,exports){21877 -1 arguments[4][55][0].apply(exports,arguments)21878 -1 },{"_process":149,"dup":55}],112:[function(require,module,exports){21879 -1 arguments[4][56][0].apply(exports,arguments)21880 -1 },{"../../../errors":103,"dup":56}],113:[function(require,module,exports){21881 -1 arguments[4][57][0].apply(exports,arguments)21882 -1 },{"dup":57}],114:[function(require,module,exports){21883 -1 arguments[4][58][0].apply(exports,arguments)21884 -1 },{"../../../errors":103,"./end-of-stream":112,"dup":58}],115:[function(require,module,exports){21885 -1 arguments[4][59][0].apply(exports,arguments)21886 -1 },{"../../../errors":103,"dup":59}],116:[function(require,module,exports){21887 -1 arguments[4][60][0].apply(exports,arguments)21888 -1 },{"dup":60,"events":100}],117:[function(require,module,exports){21889 -1 arguments[4][61][0].apply(exports,arguments)21890 -1 },{"./lib/_stream_duplex.js":104,"./lib/_stream_passthrough.js":105,"./lib/_stream_readable.js":106,"./lib/_stream_transform.js":107,"./lib/_stream_writable.js":108,"./lib/internal/streams/end-of-stream.js":112,"./lib/internal/streams/pipeline.js":114,"dup":61}],118:[function(require,module,exports){21891 -1 var hash = exports;21892 -121893 -1 hash.utils = require('./hash/utils');21894 -1 hash.common = require('./hash/common');21895 -1 hash.sha = require('./hash/sha');21896 -1 hash.ripemd = require('./hash/ripemd');21897 -1 hash.hmac = require('./hash/hmac');21898 -121899 -1 // Proxy hash functions to the main object21900 -1 hash.sha1 = hash.sha.sha1;21901 -1 hash.sha256 = hash.sha.sha256;21902 -1 hash.sha224 = hash.sha.sha224;21903 -1 hash.sha384 = hash.sha.sha384;21904 -1 hash.sha512 = hash.sha.sha512;21905 -1 hash.ripemd160 = hash.ripemd.ripemd160;21906 -121907 -1 },{"./hash/common":119,"./hash/hmac":120,"./hash/ripemd":121,"./hash/sha":122,"./hash/utils":129}],119:[function(require,module,exports){21908 -1 'use strict';21909 -121910 -1 var utils = require('./utils');21911 -1 var assert = require('minimalistic-assert');21912 -121913 -1 function BlockHash() {21914 -1 this.pending = null;21915 -1 this.pendingTotal = 0;21916 -1 this.blockSize = this.constructor.blockSize;21917 -1 this.outSize = this.constructor.outSize;21918 -1 this.hmacStrength = this.constructor.hmacStrength;21919 -1 this.padLength = this.constructor.padLength / 8;21920 -1 this.endian = 'big';21921 -121922 -1 this._delta8 = this.blockSize / 8;21923 -1 this._delta32 = this.blockSize / 32;21924 -1 }21925 -1 exports.BlockHash = BlockHash;21926 -121927 -1 BlockHash.prototype.update = function update(msg, enc) {21928 -1 // Convert message to array, pad it, and join into 32bit blocks21929 -1 msg = utils.toArray(msg, enc);21930 -1 if (!this.pending)21931 -1 this.pending = msg;21932 -1 else21933 -1 this.pending = this.pending.concat(msg);21934 -1 this.pendingTotal += msg.length;21935 -121936 -1 // Enough data, try updating21937 -1 if (this.pending.length >= this._delta8) {21938 -1 msg = this.pending;21939 -121940 -1 // Process pending data in blocks21941 -1 var r = msg.length % this._delta8;21942 -1 this.pending = msg.slice(msg.length - r, msg.length);21943 -1 if (this.pending.length === 0)21944 -1 this.pending = null;21945 -121946 -1 msg = utils.join32(msg, 0, msg.length - r, this.endian);21947 -1 for (var i = 0; i < msg.length; i += this._delta32)21948 -1 this._update(msg, i, i + this._delta32);21949 -1 }21950 -121951 -1 return this;21952 -1 };21953 -121954 -1 BlockHash.prototype.digest = function digest(enc) {21955 -1 this.update(this._pad());21956 -1 assert(this.pending === null);21957 -121958 -1 return this._digest(enc);21959 -1 };21960 -121961 -1 BlockHash.prototype._pad = function pad() {21962 -1 var len = this.pendingTotal;21963 -1 var bytes = this._delta8;21964 -1 var k = bytes - ((len + this.padLength) % bytes);21965 -1 var res = new Array(k + this.padLength);21966 -1 res[0] = 0x80;21967 -1 for (var i = 1; i < k; i++)21968 -1 res[i] = 0;21969 -121970 -1 // Append length21971 -1 len <<= 3;21972 -1 if (this.endian === 'big') {21973 -1 for (var t = 8; t < this.padLength; t++)21974 -1 res[i++] = 0;21975 -121976 -1 res[i++] = 0;21977 -1 res[i++] = 0;21978 -1 res[i++] = 0;21979 -1 res[i++] = 0;21980 -1 res[i++] = (len >>> 24) & 0xff;21981 -1 res[i++] = (len >>> 16) & 0xff;21982 -1 res[i++] = (len >>> 8) & 0xff;21983 -1 res[i++] = len & 0xff;21984 -1 } else {21985 -1 res[i++] = len & 0xff;21986 -1 res[i++] = (len >>> 8) & 0xff;21987 -1 res[i++] = (len >>> 16) & 0xff;21988 -1 res[i++] = (len >>> 24) & 0xff;21989 -1 res[i++] = 0;21990 -1 res[i++] = 0;21991 -1 res[i++] = 0;21992 -1 res[i++] = 0;21993 -121994 -1 for (t = 8; t < this.padLength; t++)21995 -1 res[i++] = 0;21996 -1 }21997 -121998 -1 return res;21999 -1 };22000 -122001 -1 },{"./utils":129,"minimalistic-assert":136}],120:[function(require,module,exports){22002 -1 'use strict';22003 -122004 -1 var utils = require('./utils');22005 -1 var assert = require('minimalistic-assert');22006 -122007 -1 function Hmac(hash, key, enc) {22008 -1 if (!(this instanceof Hmac))22009 -1 return new Hmac(hash, key, enc);22010 -1 this.Hash = hash;22011 -1 this.blockSize = hash.blockSize / 8;22012 -1 this.outSize = hash.outSize / 8;22013 -1 this.inner = null;22014 -1 this.outer = null;22015 -122016 -1 this._init(utils.toArray(key, enc));22017 -1 }22018 -1 module.exports = Hmac;22019 -122020 -1 Hmac.prototype._init = function init(key) {22021 -1 // Shorten key, if needed22022 -1 if (key.length > this.blockSize)22023 -1 key = new this.Hash().update(key).digest();22024 -1 assert(key.length <= this.blockSize);22025 -122026 -1 // Add padding to key22027 -1 for (var i = key.length; i < this.blockSize; i++)22028 -1 key.push(0);22029 -122030 -1 for (i = 0; i < key.length; i++)22031 -1 key[i] ^= 0x36;22032 -1 this.inner = new this.Hash().update(key);22033 -122034 -1 // 0x36 ^ 0x5c = 0x6a22035 -1 for (i = 0; i < key.length; i++)22036 -1 key[i] ^= 0x6a;22037 -1 this.outer = new this.Hash().update(key);22038 -1 };22039 -122040 -1 Hmac.prototype.update = function update(msg, enc) {22041 -1 this.inner.update(msg, enc);22042 -1 return this;22043 -1 };22044 -122045 -1 Hmac.prototype.digest = function digest(enc) {22046 -1 this.outer.update(this.inner.digest());22047 -1 return this.outer.digest(enc);22048 -1 };22049 -122050 -1 },{"./utils":129,"minimalistic-assert":136}],121:[function(require,module,exports){22051 -1 'use strict';22052 -122053 -1 var utils = require('./utils');22054 -1 var common = require('./common');22055 -122056 -1 var rotl32 = utils.rotl32;22057 -1 var sum32 = utils.sum32;22058 -1 var sum32_3 = utils.sum32_3;22059 -1 var sum32_4 = utils.sum32_4;22060 -1 var BlockHash = common.BlockHash;22061 -122062 -1 function RIPEMD160() {22063 -1 if (!(this instanceof RIPEMD160))22064 -1 return new RIPEMD160();22065 -122066 -1 BlockHash.call(this);22067 -122068 -1 this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];22069 -1 this.endian = 'little';22070 -1 }22071 -1 utils.inherits(RIPEMD160, BlockHash);22072 -1 exports.ripemd160 = RIPEMD160;22073 -122074 -1 RIPEMD160.blockSize = 512;22075 -1 RIPEMD160.outSize = 160;22076 -1 RIPEMD160.hmacStrength = 192;22077 -1 RIPEMD160.padLength = 64;22078 -122079 -1 RIPEMD160.prototype._update = function update(msg, start) {22080 -1 var A = this.h[0];22081 -1 var B = this.h[1];22082 -1 var C = this.h[2];22083 -1 var D = this.h[3];22084 -1 var E = this.h[4];22085 -1 var Ah = A;22086 -1 var Bh = B;22087 -1 var Ch = C;22088 -1 var Dh = D;22089 -1 var Eh = E;22090 -1 for (var j = 0; j < 80; j++) {22091 -1 var T = sum32(22092 -1 rotl32(22093 -1 sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),22094 -1 s[j]),22095 -1 E);22096 -1 A = E;22097 -1 E = D;22098 -1 D = rotl32(C, 10);22099 -1 C = B;22100 -1 B = T;22101 -1 T = sum32(22102 -1 rotl32(22103 -1 sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),22104 -1 sh[j]),22105 -1 Eh);22106 -1 Ah = Eh;22107 -1 Eh = Dh;22108 -1 Dh = rotl32(Ch, 10);22109 -1 Ch = Bh;22110 -1 Bh = T;22111 -1 }22112 -1 T = sum32_3(this.h[1], C, Dh);22113 -1 this.h[1] = sum32_3(this.h[2], D, Eh);22114 -1 this.h[2] = sum32_3(this.h[3], E, Ah);22115 -1 this.h[3] = sum32_3(this.h[4], A, Bh);22116 -1 this.h[4] = sum32_3(this.h[0], B, Ch);22117 -1 this.h[0] = T;22118 -1 };22119 -122120 -1 RIPEMD160.prototype._digest = function digest(enc) {22121 -1 if (enc === 'hex')22122 -1 return utils.toHex32(this.h, 'little');22123 -1 else22124 -1 return utils.split32(this.h, 'little');22125 -1 };22126 -122127 -1 function f(j, x, y, z) {22128 -1 if (j <= 15)22129 -1 return x ^ y ^ z;22130 -1 else if (j <= 31)22131 -1 return (x & y) | ((~x) & z);22132 -1 else if (j <= 47)22133 -1 return (x | (~y)) ^ z;22134 -1 else if (j <= 63)22135 -1 return (x & z) | (y & (~z));22136 -1 else22137 -1 return x ^ (y | (~z));22138 -1 }22139 -122140 -1 function K(j) {22141 -1 if (j <= 15)22142 -1 return 0x00000000;22143 -1 else if (j <= 31)22144 -1 return 0x5a827999;22145 -1 else if (j <= 47)22146 -1 return 0x6ed9eba1;22147 -1 else if (j <= 63)22148 -1 return 0x8f1bbcdc;22149 -1 else22150 -1 return 0xa953fd4e;22151 -1 }22152 -122153 -1 function Kh(j) {22154 -1 if (j <= 15)22155 -1 return 0x50a28be6;22156 -1 else if (j <= 31)22157 -1 return 0x5c4dd124;22158 -1 else if (j <= 47)22159 -1 return 0x6d703ef3;22160 -1 else if (j <= 63)22161 -1 return 0x7a6d76e9;22162 -1 else22163 -1 return 0x00000000;22164 -1 }22165 -122166 -1 var r = [22167 -1 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,22168 -1 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,22169 -1 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,22170 -1 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,22171 -1 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 1322172 -1 ];22173 -122174 -1 var rh = [22175 -1 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,22176 -1 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,22177 -1 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,22178 -1 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,22179 -1 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 1122180 -1 ];22181 -122182 -1 var s = [22183 -1 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,22184 -1 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,22185 -1 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,22186 -1 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,22187 -1 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 622188 -1 ];22189 -122190 -1 var sh = [22191 -1 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,22192 -1 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,22193 -1 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,22194 -1 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,22195 -1 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 1122196 -1 ];22197 -122198 -1 },{"./common":119,"./utils":129}],122:[function(require,module,exports){22199 -1 'use strict';22200 -122201 -1 exports.sha1 = require('./sha/1');22202 -1 exports.sha224 = require('./sha/224');22203 -1 exports.sha256 = require('./sha/256');22204 -1 exports.sha384 = require('./sha/384');22205 -1 exports.sha512 = require('./sha/512');22206 -122207 -1 },{"./sha/1":123,"./sha/224":124,"./sha/256":125,"./sha/384":126,"./sha/512":127}],123:[function(require,module,exports){22208 -1 'use strict';22209 -122210 -1 var utils = require('../utils');22211 -1 var common = require('../common');22212 -1 var shaCommon = require('./common');22213 -122214 -1 var rotl32 = utils.rotl32;22215 -1 var sum32 = utils.sum32;22216 -1 var sum32_5 = utils.sum32_5;22217 -1 var ft_1 = shaCommon.ft_1;22218 -1 var BlockHash = common.BlockHash;22219 -122220 -1 var sha1_K = [22221 -1 0x5A827999, 0x6ED9EBA1,22222 -1 0x8F1BBCDC, 0xCA62C1D622223 -1 ];22224 -122225 -1 function SHA1() {22226 -1 if (!(this instanceof SHA1))22227 -1 return new SHA1();22228 -122229 -1 BlockHash.call(this);22230 -1 this.h = [22231 -1 0x67452301, 0xefcdab89, 0x98badcfe,22232 -1 0x10325476, 0xc3d2e1f0 ];22233 -1 this.W = new Array(80);22234 -1 }22235 -122236 -1 utils.inherits(SHA1, BlockHash);22237 -1 module.exports = SHA1;22238 -122239 -1 SHA1.blockSize = 512;22240 -1 SHA1.outSize = 160;22241 -1 SHA1.hmacStrength = 80;22242 -1 SHA1.padLength = 64;22243 -122244 -1 SHA1.prototype._update = function _update(msg, start) {22245 -1 var W = this.W;22246 -122247 -1 for (var i = 0; i < 16; i++)22248 -1 W[i] = msg[start + i];22249 -122250 -1 for(; i < W.length; i++)22251 -1 W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);22252 -122253 -1 var a = this.h[0];22254 -1 var b = this.h[1];22255 -1 var c = this.h[2];22256 -1 var d = this.h[3];22257 -1 var e = this.h[4];22258 -122259 -1 for (i = 0; i < W.length; i++) {22260 -1 var s = ~~(i / 20);22261 -1 var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);22262 -1 e = d;22263 -1 d = c;22264 -1 c = rotl32(b, 30);22265 -1 b = a;22266 -1 a = t;22267 -1 }22268 -122269 -1 this.h[0] = sum32(this.h[0], a);22270 -1 this.h[1] = sum32(this.h[1], b);22271 -1 this.h[2] = sum32(this.h[2], c);22272 -1 this.h[3] = sum32(this.h[3], d);22273 -1 this.h[4] = sum32(this.h[4], e);22274 -1 };22275 -122276 -1 SHA1.prototype._digest = function digest(enc) {22277 -1 if (enc === 'hex')22278 -1 return utils.toHex32(this.h, 'big');22279 -1 else22280 -1 return utils.split32(this.h, 'big');22281 -1 };22282 -122283 -1 },{"../common":119,"../utils":129,"./common":128}],124:[function(require,module,exports){22284 -1 'use strict';22285 -122286 -1 var utils = require('../utils');22287 -1 var SHA256 = require('./256');22288 -122289 -1 function SHA224() {22290 -1 if (!(this instanceof SHA224))22291 -1 return new SHA224();22292 -122293 -1 SHA256.call(this);22294 -1 this.h = [22295 -1 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,22296 -1 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];22297 -1 }22298 -1 utils.inherits(SHA224, SHA256);22299 -1 module.exports = SHA224;22300 -122301 -1 SHA224.blockSize = 512;22302 -1 SHA224.outSize = 224;22303 -1 SHA224.hmacStrength = 192;22304 -1 SHA224.padLength = 64;22305 -122306 -1 SHA224.prototype._digest = function digest(enc) {22307 -1 // Just truncate output22308 -1 if (enc === 'hex')22309 -1 return utils.toHex32(this.h.slice(0, 7), 'big');22310 -1 else22311 -1 return utils.split32(this.h.slice(0, 7), 'big');22312 -1 };22313 -122314 -122315 -1 },{"../utils":129,"./256":125}],125:[function(require,module,exports){22316 -1 'use strict';22317 -122318 -1 var utils = require('../utils');22319 -1 var common = require('../common');22320 -1 var shaCommon = require('./common');22321 -1 var assert = require('minimalistic-assert');22322 -122323 -1 var sum32 = utils.sum32;22324 -1 var sum32_4 = utils.sum32_4;22325 -1 var sum32_5 = utils.sum32_5;22326 -1 var ch32 = shaCommon.ch32;22327 -1 var maj32 = shaCommon.maj32;22328 -1 var s0_256 = shaCommon.s0_256;22329 -1 var s1_256 = shaCommon.s1_256;22330 -1 var g0_256 = shaCommon.g0_256;22331 -1 var g1_256 = shaCommon.g1_256;22332 -122333 -1 var BlockHash = common.BlockHash;22334 -122335 -1 var sha256_K = [22336 -1 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,22337 -1 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,22338 -1 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,22339 -1 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,22340 -1 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,22341 -1 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,22342 -1 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,22343 -1 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,22344 -1 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,22345 -1 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,22346 -1 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,22347 -1 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,22348 -1 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,22349 -1 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,22350 -1 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,22351 -1 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f222352 -1 ];22353 -122354 -1 function SHA256() {22355 -1 if (!(this instanceof SHA256))22356 -1 return new SHA256();22357 -122358 -1 BlockHash.call(this);22359 -1 this.h = [22360 -1 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,22361 -1 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd1922362 -1 ];22363 -1 this.k = sha256_K;22364 -1 this.W = new Array(64);22365 -1 }22366 -1 utils.inherits(SHA256, BlockHash);22367 -1 module.exports = SHA256;22368 -122369 -1 SHA256.blockSize = 512;22370 -1 SHA256.outSize = 256;22371 -1 SHA256.hmacStrength = 192;22372 -1 SHA256.padLength = 64;22373 -122374 -1 SHA256.prototype._update = function _update(msg, start) {22375 -1 var W = this.W;22376 -122377 -1 for (var i = 0; i < 16; i++)22378 -1 W[i] = msg[start + i];22379 -1 for (; i < W.length; i++)22380 -1 W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);22381 -122382 -1 var a = this.h[0];22383 -1 var b = this.h[1];22384 -1 var c = this.h[2];22385 -1 var d = this.h[3];22386 -1 var e = this.h[4];22387 -1 var f = this.h[5];22388 -1 var g = this.h[6];22389 -1 var h = this.h[7];22390 -122391 -1 assert(this.k.length === W.length);22392 -1 for (i = 0; i < W.length; i++) {22393 -1 var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);22394 -1 var T2 = sum32(s0_256(a), maj32(a, b, c));22395 -1 h = g;22396 -1 g = f;22397 -1 f = e;22398 -1 e = sum32(d, T1);22399 -1 d = c;22400 -1 c = b;22401 -1 b = a;22402 -1 a = sum32(T1, T2);22403 -1 }22404 -122405 -1 this.h[0] = sum32(this.h[0], a);22406 -1 this.h[1] = sum32(this.h[1], b);22407 -1 this.h[2] = sum32(this.h[2], c);22408 -1 this.h[3] = sum32(this.h[3], d);22409 -1 this.h[4] = sum32(this.h[4], e);22410 -1 this.h[5] = sum32(this.h[5], f);22411 -1 this.h[6] = sum32(this.h[6], g);22412 -1 this.h[7] = sum32(this.h[7], h);22413 -1 };22414 -122415 -1 SHA256.prototype._digest = function digest(enc) {22416 -1 if (enc === 'hex')22417 -1 return utils.toHex32(this.h, 'big');22418 -1 else22419 -1 return utils.split32(this.h, 'big');22420 -1 };22421 -122422 -1 },{"../common":119,"../utils":129,"./common":128,"minimalistic-assert":136}],126:[function(require,module,exports){22423 -1 'use strict';22424 -122425 -1 var utils = require('../utils');22426 -122427 -1 var SHA512 = require('./512');22428 -122429 -1 function SHA384() {22430 -1 if (!(this instanceof SHA384))22431 -1 return new SHA384();22432 -122433 -1 SHA512.call(this);22434 -1 this.h = [22435 -1 0xcbbb9d5d, 0xc1059ed8,22436 -1 0x629a292a, 0x367cd507,22437 -1 0x9159015a, 0x3070dd17,22438 -1 0x152fecd8, 0xf70e5939,22439 -1 0x67332667, 0xffc00b31,22440 -1 0x8eb44a87, 0x68581511,22441 -1 0xdb0c2e0d, 0x64f98fa7,22442 -1 0x47b5481d, 0xbefa4fa4 ];22443 -1 }22444 -1 utils.inherits(SHA384, SHA512);22445 -1 module.exports = SHA384;22446 -122447 -1 SHA384.blockSize = 1024;22448 -1 SHA384.outSize = 384;22449 -1 SHA384.hmacStrength = 192;22450 -1 SHA384.padLength = 128;22451 -122452 -1 SHA384.prototype._digest = function digest(enc) {22453 -1 if (enc === 'hex')22454 -1 return utils.toHex32(this.h.slice(0, 12), 'big');22455 -1 else22456 -1 return utils.split32(this.h.slice(0, 12), 'big');22457 -1 };22458 -122459 -1 },{"../utils":129,"./512":127}],127:[function(require,module,exports){22460 -1 'use strict';22461 -122462 -1 var utils = require('../utils');22463 -1 var common = require('../common');22464 -1 var assert = require('minimalistic-assert');22465 -122466 -1 var rotr64_hi = utils.rotr64_hi;22467 -1 var rotr64_lo = utils.rotr64_lo;22468 -1 var shr64_hi = utils.shr64_hi;22469 -1 var shr64_lo = utils.shr64_lo;22470 -1 var sum64 = utils.sum64;22471 -1 var sum64_hi = utils.sum64_hi;22472 -1 var sum64_lo = utils.sum64_lo;22473 -1 var sum64_4_hi = utils.sum64_4_hi;22474 -1 var sum64_4_lo = utils.sum64_4_lo;22475 -1 var sum64_5_hi = utils.sum64_5_hi;22476 -1 var sum64_5_lo = utils.sum64_5_lo;22477 -122478 -1 var BlockHash = common.BlockHash;22479 -122480 -1 var sha512_K = [22481 -1 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,22482 -1 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,22483 -1 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,22484 -1 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,22485 -1 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,22486 -1 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,22487 -1 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,22488 -1 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,22489 -1 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,22490 -1 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,22491 -1 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,22492 -1 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,22493 -1 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,22494 -1 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,22495 -1 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,22496 -1 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,22497 -1 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,22498 -1 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,22499 -1 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,22500 -1 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,22501 -1 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,22502 -1 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,22503 -1 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,22504 -1 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,22505 -1 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,22506 -1 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,22507 -1 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,22508 -1 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,22509 -1 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,22510 -1 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,22511 -1 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,22512 -1 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,22513 -1 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,22514 -1 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,22515 -1 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,22516 -1 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,22517 -1 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,22518 -1 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,22519 -1 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,22520 -1 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a47581722521 -1 ];22522 -122523 -1 function SHA512() {22524 -1 if (!(this instanceof SHA512))22525 -1 return new SHA512();22526 -122527 -1 BlockHash.call(this);22528 -1 this.h = [22529 -1 0x6a09e667, 0xf3bcc908,22530 -1 0xbb67ae85, 0x84caa73b,22531 -1 0x3c6ef372, 0xfe94f82b,22532 -1 0xa54ff53a, 0x5f1d36f1,22533 -1 0x510e527f, 0xade682d1,22534 -1 0x9b05688c, 0x2b3e6c1f,22535 -1 0x1f83d9ab, 0xfb41bd6b,22536 -1 0x5be0cd19, 0x137e2179 ];22537 -1 this.k = sha512_K;22538 -1 this.W = new Array(160);22539 -1 }22540 -1 utils.inherits(SHA512, BlockHash);22541 -1 module.exports = SHA512;22542 -122543 -1 SHA512.blockSize = 1024;22544 -1 SHA512.outSize = 512;22545 -1 SHA512.hmacStrength = 192;22546 -1 SHA512.padLength = 128;22547 -122548 -1 SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {22549 -1 var W = this.W;22550 -122551 -1 // 32 x 32bit words22552 -1 for (var i = 0; i < 32; i++)22553 -1 W[i] = msg[start + i];22554 -1 for (; i < W.length; i += 2) {22555 -1 var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 222556 -1 var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);22557 -1 var c1_hi = W[i - 14]; // i - 722558 -1 var c1_lo = W[i - 13];22559 -1 var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 1522560 -1 var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);22561 -1 var c3_hi = W[i - 32]; // i - 1622562 -1 var c3_lo = W[i - 31];22563 -122564 -1 W[i] = sum64_4_hi(22565 -1 c0_hi, c0_lo,22566 -1 c1_hi, c1_lo,22567 -1 c2_hi, c2_lo,22568 -1 c3_hi, c3_lo);22569 -1 W[i + 1] = sum64_4_lo(22570 -1 c0_hi, c0_lo,22571 -1 c1_hi, c1_lo,22572 -1 c2_hi, c2_lo,22573 -1 c3_hi, c3_lo);22574 -1 }22575 -1 };22576 -122577 -1 SHA512.prototype._update = function _update(msg, start) {22578 -1 this._prepareBlock(msg, start);22579 -122580 -1 var W = this.W;22581 -122582 -1 var ah = this.h[0];22583 -1 var al = this.h[1];22584 -1 var bh = this.h[2];22585 -1 var bl = this.h[3];22586 -1 var ch = this.h[4];22587 -1 var cl = this.h[5];22588 -1 var dh = this.h[6];22589 -1 var dl = this.h[7];22590 -1 var eh = this.h[8];22591 -1 var el = this.h[9];22592 -1 var fh = this.h[10];22593 -1 var fl = this.h[11];22594 -1 var gh = this.h[12];22595 -1 var gl = this.h[13];22596 -1 var hh = this.h[14];22597 -1 var hl = this.h[15];22598 -122599 -1 assert(this.k.length === W.length);22600 -1 for (var i = 0; i < W.length; i += 2) {22601 -1 var c0_hi = hh;22602 -1 var c0_lo = hl;22603 -1 var c1_hi = s1_512_hi(eh, el);22604 -1 var c1_lo = s1_512_lo(eh, el);22605 -1 var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);22606 -1 var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);22607 -1 var c3_hi = this.k[i];22608 -1 var c3_lo = this.k[i + 1];22609 -1 var c4_hi = W[i];22610 -1 var c4_lo = W[i + 1];22611 -122612 -1 var T1_hi = sum64_5_hi(22613 -1 c0_hi, c0_lo,22614 -1 c1_hi, c1_lo,22615 -1 c2_hi, c2_lo,22616 -1 c3_hi, c3_lo,22617 -1 c4_hi, c4_lo);22618 -1 var T1_lo = sum64_5_lo(22619 -1 c0_hi, c0_lo,22620 -1 c1_hi, c1_lo,22621 -1 c2_hi, c2_lo,22622 -1 c3_hi, c3_lo,22623 -1 c4_hi, c4_lo);22624 -122625 -1 c0_hi = s0_512_hi(ah, al);22626 -1 c0_lo = s0_512_lo(ah, al);22627 -1 c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);22628 -1 c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);22629 -122630 -1 var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);22631 -1 var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);22632 -122633 -1 hh = gh;22634 -1 hl = gl;22635 -122636 -1 gh = fh;22637 -1 gl = fl;22638 -122639 -1 fh = eh;22640 -1 fl = el;22641 -122642 -1 eh = sum64_hi(dh, dl, T1_hi, T1_lo);22643 -1 el = sum64_lo(dl, dl, T1_hi, T1_lo);22644 -122645 -1 dh = ch;22646 -1 dl = cl;22647 -122648 -1 ch = bh;22649 -1 cl = bl;22650 -122651 -1 bh = ah;22652 -1 bl = al;22653 -122654 -1 ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);22655 -1 al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);22656 -1 }22657 -122658 -1 sum64(this.h, 0, ah, al);22659 -1 sum64(this.h, 2, bh, bl);22660 -1 sum64(this.h, 4, ch, cl);22661 -1 sum64(this.h, 6, dh, dl);22662 -1 sum64(this.h, 8, eh, el);22663 -1 sum64(this.h, 10, fh, fl);22664 -1 sum64(this.h, 12, gh, gl);22665 -1 sum64(this.h, 14, hh, hl);22666 -1 };22667 -122668 -1 SHA512.prototype._digest = function digest(enc) {22669 -1 if (enc === 'hex')22670 -1 return utils.toHex32(this.h, 'big');22671 -1 else22672 -1 return utils.split32(this.h, 'big');22673 -1 };22674 -122675 -1 function ch64_hi(xh, xl, yh, yl, zh) {22676 -1 var r = (xh & yh) ^ ((~xh) & zh);22677 -1 if (r < 0)22678 -1 r += 0x100000000;22679 -1 return r;22680 -1 }22681 -122682 -1 function ch64_lo(xh, xl, yh, yl, zh, zl) {22683 -1 var r = (xl & yl) ^ ((~xl) & zl);22684 -1 if (r < 0)22685 -1 r += 0x100000000;22686 -1 return r;22687 -1 }22688 -122689 -1 function maj64_hi(xh, xl, yh, yl, zh) {22690 -1 var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);22691 -1 if (r < 0)22692 -1 r += 0x100000000;22693 -1 return r;22694 -1 }22695 -122696 -1 function maj64_lo(xh, xl, yh, yl, zh, zl) {22697 -1 var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);22698 -1 if (r < 0)22699 -1 r += 0x100000000;22700 -1 return r;22701 -1 }22702 -122703 -1 function s0_512_hi(xh, xl) {22704 -1 var c0_hi = rotr64_hi(xh, xl, 28);22705 -1 var c1_hi = rotr64_hi(xl, xh, 2); // 3422706 -1 var c2_hi = rotr64_hi(xl, xh, 7); // 3922707 -122708 -1 var r = c0_hi ^ c1_hi ^ c2_hi;22709 -1 if (r < 0)22710 -1 r += 0x100000000;22711 -1 return r;22712 -1 }22713 -122714 -1 function s0_512_lo(xh, xl) {22715 -1 var c0_lo = rotr64_lo(xh, xl, 28);22716 -1 var c1_lo = rotr64_lo(xl, xh, 2); // 3422717 -1 var c2_lo = rotr64_lo(xl, xh, 7); // 3922718 -122719 -1 var r = c0_lo ^ c1_lo ^ c2_lo;22720 -1 if (r < 0)22721 -1 r += 0x100000000;22722 -1 return r;22723 -1 }22724 -122725 -1 function s1_512_hi(xh, xl) {22726 -1 var c0_hi = rotr64_hi(xh, xl, 14);22727 -1 var c1_hi = rotr64_hi(xh, xl, 18);22728 -1 var c2_hi = rotr64_hi(xl, xh, 9); // 4122729 -122730 -1 var r = c0_hi ^ c1_hi ^ c2_hi;22731 -1 if (r < 0)22732 -1 r += 0x100000000;22733 -1 return r;22734 -1 }22735 -122736 -1 function s1_512_lo(xh, xl) {22737 -1 var c0_lo = rotr64_lo(xh, xl, 14);22738 -1 var c1_lo = rotr64_lo(xh, xl, 18);22739 -1 var c2_lo = rotr64_lo(xl, xh, 9); // 4122740 -122741 -1 var r = c0_lo ^ c1_lo ^ c2_lo;22742 -1 if (r < 0)22743 -1 r += 0x100000000;22744 -1 return r;22745 -1 }22746 -122747 -1 function g0_512_hi(xh, xl) {22748 -1 var c0_hi = rotr64_hi(xh, xl, 1);22749 -1 var c1_hi = rotr64_hi(xh, xl, 8);22750 -1 var c2_hi = shr64_hi(xh, xl, 7);22751 -122752 -1 var r = c0_hi ^ c1_hi ^ c2_hi;22753 -1 if (r < 0)22754 -1 r += 0x100000000;22755 -1 return r;22756 -1 }22757 -122758 -1 function g0_512_lo(xh, xl) {22759 -1 var c0_lo = rotr64_lo(xh, xl, 1);22760 -1 var c1_lo = rotr64_lo(xh, xl, 8);22761 -1 var c2_lo = shr64_lo(xh, xl, 7);22762 -122763 -1 var r = c0_lo ^ c1_lo ^ c2_lo;22764 -1 if (r < 0)22765 -1 r += 0x100000000;22766 -1 return r;22767 -1 }22768 -122769 -1 function g1_512_hi(xh, xl) {22770 -1 var c0_hi = rotr64_hi(xh, xl, 19);22771 -1 var c1_hi = rotr64_hi(xl, xh, 29); // 6122772 -1 var c2_hi = shr64_hi(xh, xl, 6);22773 -122774 -1 var r = c0_hi ^ c1_hi ^ c2_hi;22775 -1 if (r < 0)22776 -1 r += 0x100000000;22777 -1 return r;22778 -1 }22779 -122780 -1 function g1_512_lo(xh, xl) {22781 -1 var c0_lo = rotr64_lo(xh, xl, 19);22782 -1 var c1_lo = rotr64_lo(xl, xh, 29); // 6122783 -1 var c2_lo = shr64_lo(xh, xl, 6);22784 -122785 -1 var r = c0_lo ^ c1_lo ^ c2_lo;22786 -1 if (r < 0)22787 -1 r += 0x100000000;22788 -1 return r;22789 -1 }22790 -122791 -1 },{"../common":119,"../utils":129,"minimalistic-assert":136}],128:[function(require,module,exports){22792 -1 'use strict';22793 -122794 -1 var utils = require('../utils');22795 -1 var rotr32 = utils.rotr32;22796 -122797 -1 function ft_1(s, x, y, z) {22798 -1 if (s === 0)22799 -1 return ch32(x, y, z);22800 -1 if (s === 1 || s === 3)22801 -1 return p32(x, y, z);22802 -1 if (s === 2)22803 -1 return maj32(x, y, z);22804 -1 }22805 -1 exports.ft_1 = ft_1;22806 -122807 -1 function ch32(x, y, z) {22808 -1 return (x & y) ^ ((~x) & z);22809 -1 }22810 -1 exports.ch32 = ch32;22811 -122812 -1 function maj32(x, y, z) {22813 -1 return (x & y) ^ (x & z) ^ (y & z);22814 -1 }22815 -1 exports.maj32 = maj32;22816 -122817 -1 function p32(x, y, z) {22818 -1 return x ^ y ^ z;22819 -1 }22820 -1 exports.p32 = p32;22821 -122822 -1 function s0_256(x) {22823 -1 return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);22824 -1 }22825 -1 exports.s0_256 = s0_256;22826 -122827 -1 function s1_256(x) {22828 -1 return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);22829 -1 }22830 -1 exports.s1_256 = s1_256;22831 -122832 -1 function g0_256(x) {22833 -1 return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);22834 -1 }22835 -1 exports.g0_256 = g0_256;22836 -122837 -1 function g1_256(x) {22838 -1 return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);22839 -1 }22840 -1 exports.g1_256 = g1_256;22841 -122842 -1 },{"../utils":129}],129:[function(require,module,exports){22843 -1 'use strict';22844 -122845 -1 var assert = require('minimalistic-assert');22846 -1 var inherits = require('inherits');22847 -122848 -1 exports.inherits = inherits;22849 -122850 -1 function isSurrogatePair(msg, i) {22851 -1 if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {22852 -1 return false;22853 -1 }22854 -1 if (i < 0 || i + 1 >= msg.length) {22855 -1 return false;22856 -1 }22857 -1 return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;22858 -1 }22859 -122860 -1 function toArray(msg, enc) {22861 -1 if (Array.isArray(msg))22862 -1 return msg.slice();22863 -1 if (!msg)22864 -1 return [];22865 -1 var res = [];22866 -1 if (typeof msg === 'string') {22867 -1 if (!enc) {22868 -1 // Inspired by stringToUtf8ByteArray() in closure-library by Google22869 -1 // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L14322870 -1 // Apache License 2.022871 -1 // https://github.com/google/closure-library/blob/master/LICENSE22872 -1 var p = 0;22873 -1 for (var i = 0; i < msg.length; i++) {22874 -1 var c = msg.charCodeAt(i);22875 -1 if (c < 128) {22876 -1 res[p++] = c;22877 -1 } else if (c < 2048) {22878 -1 res[p++] = (c >> 6) | 192;22879 -1 res[p++] = (c & 63) | 128;22880 -1 } else if (isSurrogatePair(msg, i)) {22881 -1 c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);22882 -1 res[p++] = (c >> 18) | 240;22883 -1 res[p++] = ((c >> 12) & 63) | 128;22884 -1 res[p++] = ((c >> 6) & 63) | 128;22885 -1 res[p++] = (c & 63) | 128;22886 -1 } else {22887 -1 res[p++] = (c >> 12) | 224;22888 -1 res[p++] = ((c >> 6) & 63) | 128;22889 -1 res[p++] = (c & 63) | 128;22890 -1 }22891 -1 }22892 -1 } else if (enc === 'hex') {22893 -1 msg = msg.replace(/[^a-z0-9]+/ig, '');22894 -1 if (msg.length % 2 !== 0)22895 -1 msg = '0' + msg;22896 -1 for (i = 0; i < msg.length; i += 2)22897 -1 res.push(parseInt(msg[i] + msg[i + 1], 16));22898 -1 }22899 -1 } else {22900 -1 for (i = 0; i < msg.length; i++)22901 -1 res[i] = msg[i] | 0;22902 -1 }22903 -1 return res;22904 -1 }22905 -1 exports.toArray = toArray;22906 -122907 -1 function toHex(msg) {22908 -1 var res = '';22909 -1 for (var i = 0; i < msg.length; i++)22910 -1 res += zero2(msg[i].toString(16));22911 -1 return res;22912 -1 }22913 -1 exports.toHex = toHex;22914 -122915 -1 function htonl(w) {22916 -1 var res = (w >>> 24) |22917 -1 ((w >>> 8) & 0xff00) |22918 -1 ((w << 8) & 0xff0000) |22919 -1 ((w & 0xff) << 24);22920 -1 return res >>> 0;22921 -1 }22922 -1 exports.htonl = htonl;22923 -122924 -1 function toHex32(msg, endian) {22925 -1 var res = '';22926 -1 for (var i = 0; i < msg.length; i++) {22927 -1 var w = msg[i];22928 -1 if (endian === 'little')22929 -1 w = htonl(w);22930 -1 res += zero8(w.toString(16));22931 -1 }22932 -1 return res;22933 -1 }22934 -1 exports.toHex32 = toHex32;22935 -122936 -1 function zero2(word) {22937 -1 if (word.length === 1)22938 -1 return '0' + word;22939 -1 else22940 -1 return word;22941 -1 }22942 -1 exports.zero2 = zero2;22943 -122944 -1 function zero8(word) {22945 -1 if (word.length === 7)22946 -1 return '0' + word;22947 -1 else if (word.length === 6)22948 -1 return '00' + word;22949 -1 else if (word.length === 5)22950 -1 return '000' + word;22951 -1 else if (word.length === 4)22952 -1 return '0000' + word;22953 -1 else if (word.length === 3)22954 -1 return '00000' + word;22955 -1 else if (word.length === 2)22956 -1 return '000000' + word;22957 -1 else if (word.length === 1)22958 -1 return '0000000' + word;22959 -1 else22960 -1 return word;22961 -1 }22962 -1 exports.zero8 = zero8;22963 -122964 -1 function join32(msg, start, end, endian) {22965 -1 var len = end - start;22966 -1 assert(len % 4 === 0);22967 -1 var res = new Array(len / 4);22968 -1 for (var i = 0, k = start; i < res.length; i++, k += 4) {22969 -1 var w;22970 -1 if (endian === 'big')22971 -1 w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];22972 -1 else22973 -1 w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];22974 -1 res[i] = w >>> 0;22975 -1 }22976 -1 return res;22977 -1 }22978 -1 exports.join32 = join32;22979 -122980 -1 function split32(msg, endian) {22981 -1 var res = new Array(msg.length * 4);22982 -1 for (var i = 0, k = 0; i < msg.length; i++, k += 4) {22983 -1 var m = msg[i];22984 -1 if (endian === 'big') {22985 -1 res[k] = m >>> 24;22986 -1 res[k + 1] = (m >>> 16) & 0xff;22987 -1 res[k + 2] = (m >>> 8) & 0xff;22988 -1 res[k + 3] = m & 0xff;22989 -1 } else {22990 -1 res[k + 3] = m >>> 24;22991 -1 res[k + 2] = (m >>> 16) & 0xff;22992 -1 res[k + 1] = (m >>> 8) & 0xff;22993 -1 res[k] = m & 0xff;22994 -1 }22995 -1 }22996 -1 return res;22997 -1 }22998 -1 exports.split32 = split32;22999 -123000 -1 function rotr32(w, b) {23001 -1 return (w >>> b) | (w << (32 - b));23002 -1 }23003 -1 exports.rotr32 = rotr32;23004 -123005 -1 function rotl32(w, b) {23006 -1 return (w << b) | (w >>> (32 - b));23007 -1 }23008 -1 exports.rotl32 = rotl32;23009 -123010 -1 function sum32(a, b) {23011 -1 return (a + b) >>> 0;23012 -1 }23013 -1 exports.sum32 = sum32;23014 -123015 -1 function sum32_3(a, b, c) {23016 -1 return (a + b + c) >>> 0;23017 -1 }23018 -1 exports.sum32_3 = sum32_3;23019 -123020 -1 function sum32_4(a, b, c, d) {23021 -1 return (a + b + c + d) >>> 0;23022 -1 }23023 -1 exports.sum32_4 = sum32_4;23024 -123025 -1 function sum32_5(a, b, c, d, e) {23026 -1 return (a + b + c + d + e) >>> 0;23027 -1 }23028 -1 exports.sum32_5 = sum32_5;23029 -123030 -1 function sum64(buf, pos, ah, al) {23031 -1 var bh = buf[pos];23032 -1 var bl = buf[pos + 1];23033 -123034 -1 var lo = (al + bl) >>> 0;23035 -1 var hi = (lo < al ? 1 : 0) + ah + bh;23036 -1 buf[pos] = hi >>> 0;23037 -1 buf[pos + 1] = lo;23038 -1 }23039 -1 exports.sum64 = sum64;23040 -123041 -1 function sum64_hi(ah, al, bh, bl) {23042 -1 var lo = (al + bl) >>> 0;23043 -1 var hi = (lo < al ? 1 : 0) + ah + bh;23044 -1 return hi >>> 0;23045 -1 }23046 -1 exports.sum64_hi = sum64_hi;23047 -123048 -1 function sum64_lo(ah, al, bh, bl) {23049 -1 var lo = al + bl;23050 -1 return lo >>> 0;23051 -1 }23052 -1 exports.sum64_lo = sum64_lo;23053 -123054 -1 function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {23055 -1 var carry = 0;23056 -1 var lo = al;23057 -1 lo = (lo + bl) >>> 0;23058 -1 carry += lo < al ? 1 : 0;23059 -1 lo = (lo + cl) >>> 0;23060 -1 carry += lo < cl ? 1 : 0;23061 -1 lo = (lo + dl) >>> 0;23062 -1 carry += lo < dl ? 1 : 0;23063 -123064 -1 var hi = ah + bh + ch + dh + carry;23065 -1 return hi >>> 0;23066 -1 }23067 -1 exports.sum64_4_hi = sum64_4_hi;23068 -123069 -1 function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {23070 -1 var lo = al + bl + cl + dl;23071 -1 return lo >>> 0;23072 -1 }23073 -1 exports.sum64_4_lo = sum64_4_lo;23074 -123075 -1 function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {23076 -1 var carry = 0;23077 -1 var lo = al;23078 -1 lo = (lo + bl) >>> 0;23079 -1 carry += lo < al ? 1 : 0;23080 -1 lo = (lo + cl) >>> 0;23081 -1 carry += lo < cl ? 1 : 0;23082 -1 lo = (lo + dl) >>> 0;23083 -1 carry += lo < dl ? 1 : 0;23084 -1 lo = (lo + el) >>> 0;23085 -1 carry += lo < el ? 1 : 0;23086 -123087 -1 var hi = ah + bh + ch + dh + eh + carry;23088 -1 return hi >>> 0;23089 -1 }23090 -1 exports.sum64_5_hi = sum64_5_hi;23091 -123092 -1 function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {23093 -1 var lo = al + bl + cl + dl + el;23094 -123095 -1 return lo >>> 0;23096 -1 }23097 -1 exports.sum64_5_lo = sum64_5_lo;23098 -123099 -1 function rotr64_hi(ah, al, num) {23100 -1 var r = (al << (32 - num)) | (ah >>> num);23101 -1 return r >>> 0;23102 -1 }23103 -1 exports.rotr64_hi = rotr64_hi;23104 -123105 -1 function rotr64_lo(ah, al, num) {23106 -1 var r = (ah << (32 - num)) | (al >>> num);23107 -1 return r >>> 0;23108 -1 }23109 -1 exports.rotr64_lo = rotr64_lo;23110 -123111 -1 function shr64_hi(ah, al, num) {23112 -1 return ah >>> num;23113 -1 }23114 -1 exports.shr64_hi = shr64_hi;23115 -123116 -1 function shr64_lo(ah, al, num) {23117 -1 var r = (ah << (32 - num)) | (al >>> num);23118 -1 return r >>> 0;23119 -1 }23120 -1 exports.shr64_lo = shr64_lo;23121 -123122 -1 },{"inherits":132,"minimalistic-assert":136}],130:[function(require,module,exports){23123 -1 'use strict';23124 -123125 -1 var hash = require('hash.js');23126 -1 var utils = require('minimalistic-crypto-utils');23127 -1 var assert = require('minimalistic-assert');23128 -123129 -1 function HmacDRBG(options) {23130 -1 if (!(this instanceof HmacDRBG))23131 -1 return new HmacDRBG(options);23132 -1 this.hash = options.hash;23133 -1 this.predResist = !!options.predResist;23134 -123135 -1 this.outLen = this.hash.outSize;23136 -1 this.minEntropy = options.minEntropy || this.hash.hmacStrength;23137 -123138 -1 this._reseed = null;23139 -1 this.reseedInterval = null;23140 -1 this.K = null;23141 -1 this.V = null;23142 -123143 -1 var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');23144 -1 var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');23145 -1 var pers = utils.toArray(options.pers, options.persEnc || 'hex');23146 -1 assert(entropy.length >= (this.minEntropy / 8),23147 -1 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');23148 -1 this._init(entropy, nonce, pers);23149 -1 }23150 -1 module.exports = HmacDRBG;23151 -123152 -1 HmacDRBG.prototype._init = function init(entropy, nonce, pers) {23153 -1 var seed = entropy.concat(nonce).concat(pers);23154 -123155 -1 this.K = new Array(this.outLen / 8);23156 -1 this.V = new Array(this.outLen / 8);23157 -1 for (var i = 0; i < this.V.length; i++) {23158 -1 this.K[i] = 0x00;23159 -1 this.V[i] = 0x01;23160 -1 }23161 -123162 -1 this._update(seed);23163 -1 this._reseed = 1;23164 -1 this.reseedInterval = 0x1000000000000; // 2^4823165 -1 };23166 -123167 -1 HmacDRBG.prototype._hmac = function hmac() {23168 -1 return new hash.hmac(this.hash, this.K);23169 -1 };23170 -123171 -1 HmacDRBG.prototype._update = function update(seed) {23172 -1 var kmac = this._hmac()23173 -1 .update(this.V)23174 -1 .update([ 0x00 ]);23175 -1 if (seed)23176 -1 kmac = kmac.update(seed);23177 -1 this.K = kmac.digest();23178 -1 this.V = this._hmac().update(this.V).digest();23179 -1 if (!seed)23180 -1 return;23181 -123182 -1 this.K = this._hmac()23183 -1 .update(this.V)23184 -1 .update([ 0x01 ])23185 -1 .update(seed)23186 -1 .digest();23187 -1 this.V = this._hmac().update(this.V).digest();23188 -1 };23189 -123190 -1 HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {23191 -1 // Optional entropy enc23192 -1 if (typeof entropyEnc !== 'string') {23193 -1 addEnc = add;23194 -1 add = entropyEnc;23195 -1 entropyEnc = null;23196 -1 }23197 -123198 -1 entropy = utils.toArray(entropy, entropyEnc);23199 -1 add = utils.toArray(add, addEnc);23200 -123201 -1 assert(entropy.length >= (this.minEntropy / 8),23202 -1 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');23203 -123204 -1 this._update(entropy.concat(add || []));23205 -1 this._reseed = 1;23206 -1 };23207 -123208 -1 HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {23209 -1 if (this._reseed > this.reseedInterval)23210 -1 throw new Error('Reseed is required');23211 -123212 -1 // Optional encoding23213 -1 if (typeof enc !== 'string') {23214 -1 addEnc = add;23215 -1 add = enc;23216 -1 enc = null;23217 -1 }23218 -123219 -1 // Optional additional data23220 -1 if (add) {23221 -1 add = utils.toArray(add, addEnc || 'hex');23222 -1 this._update(add);23223 -1 }23224 -123225 -1 var temp = [];23226 -1 while (temp.length < len) {23227 -1 this.V = this._hmac().update(this.V).digest();23228 -1 temp = temp.concat(this.V);23229 -1 }23230 -123231 -1 var res = temp.slice(0, len);23232 -1 this._update(add);23233 -1 this._reseed++;23234 -1 return utils.encode(res, enc);23235 -1 };23236 -123237 -1 },{"hash.js":118,"minimalistic-assert":136,"minimalistic-crypto-utils":137}],131:[function(require,module,exports){23238 -1 /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */23239 -1 exports.read = function (buffer, offset, isLE, mLen, nBytes) {23240 -1 var e, m23241 -1 var eLen = (nBytes * 8) - mLen - 123242 -1 var eMax = (1 << eLen) - 123243 -1 var eBias = eMax >> 123244 -1 var nBits = -723245 -1 var i = isLE ? (nBytes - 1) : 023246 -1 var d = isLE ? -1 : 123247 -1 var s = buffer[offset + i]23248 -123249 -1 i += d23250 -123251 -1 e = s & ((1 << (-nBits)) - 1)23252 -1 s >>= (-nBits)23253 -1 nBits += eLen23254 -1 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}23255 -123256 -1 m = e & ((1 << (-nBits)) - 1)23257 -1 e >>= (-nBits)23258 -1 nBits += mLen23259 -1 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}23260 -123261 -1 if (e === 0) {23262 -1 e = 1 - eBias23263 -1 } else if (e === eMax) {23264 -1 return m ? NaN : ((s ? -1 : 1) * Infinity)23265 -1 } else {23266 -1 m = m + Math.pow(2, mLen)23267 -1 e = e - eBias23268 -1 }23269 -1 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)23270 -1 }23271 -123272 -1 exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {23273 -1 var e, m, c23274 -1 var eLen = (nBytes * 8) - mLen - 123275 -1 var eMax = (1 << eLen) - 123276 -1 var eBias = eMax >> 123277 -1 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)23278 -1 var i = isLE ? 0 : (nBytes - 1)23279 -1 var d = isLE ? 1 : -123280 -1 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 023281 -123282 -1 value = Math.abs(value)23283 -123284 -1 if (isNaN(value) || value === Infinity) {23285 -1 m = isNaN(value) ? 1 : 023286 -1 e = eMax23287 -1 } else {23288 -1 e = Math.floor(Math.log(value) / Math.LN2)23289 -1 if (value * (c = Math.pow(2, -e)) < 1) {23290 -1 e--23291 -1 c *= 223292 -1 }23293 -1 if (e + eBias >= 1) {23294 -1 value += rt / c23295 -1 } else {23296 -1 value += rt * Math.pow(2, 1 - eBias)23297 -1 }23298 -1 if (value * c >= 2) {23299 -1 e++23300 -1 c /= 223301 -1 }23302 -123303 -1 if (e + eBias >= eMax) {23304 -1 m = 023305 -1 e = eMax23306 -1 } else if (e + eBias >= 1) {23307 -1 m = ((value * c) - 1) * Math.pow(2, mLen)23308 -1 e = e + eBias23309 -1 } else {23310 -1 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)23311 -1 e = 023312 -1 }23313 -1 }23314 -123315 -1 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}23316 -123317 -1 e = (e << mLen) | m23318 -1 eLen += mLen23319 -1 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}23320 -123321 -1 buffer[offset + i - d] |= s * 12823322 -1 }23323 -123324 -1 },{}],132:[function(require,module,exports){23325 -1 if (typeof Object.create === 'function') {23326 -1 // implementation from standard node.js 'util' module23327 -1 module.exports = function inherits(ctor, superCtor) {23328 -1 if (superCtor) {23329 -1 ctor.super_ = superCtor23330 -1 ctor.prototype = Object.create(superCtor.prototype, {23331 -1 constructor: {23332 -1 value: ctor,23333 -1 enumerable: false,23334 -1 writable: true,23335 -1 configurable: true23336 -1 }23337 -1 })23338 -1 }23339 -1 };23340 -1 } else {23341 -1 // old school shim for old browsers23342 -1 module.exports = function inherits(ctor, superCtor) {23343 -1 if (superCtor) {23344 -1 ctor.super_ = superCtor23345 -1 var TempCtor = function () {}23346 -1 TempCtor.prototype = superCtor.prototype23347 -1 ctor.prototype = new TempCtor()23348 -1 ctor.prototype.constructor = ctor23349 -1 }23350 -1 }23351 -1 }23352 -123353 -1 },{}],133:[function(require,module,exports){23354 -1 'use strict'23355 -1 var inherits = require('inherits')23356 -1 var HashBase = require('hash-base')23357 -1 var Buffer = require('safe-buffer').Buffer23358 -123359 -1 var ARRAY16 = new Array(16)23360 -123361 -1 function MD5 () {23362 -1 HashBase.call(this, 64)23363 -123364 -1 // state23365 -1 this._a = 0x6745230123366 -1 this._b = 0xefcdab8923367 -1 this._c = 0x98badcfe23368 -1 this._d = 0x1032547623369 -1 }23370 -123371 -1 inherits(MD5, HashBase)23372 -123373 -1 MD5.prototype._update = function () {23374 -1 var M = ARRAY1623375 -1 for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4)23376 -123377 -1 var a = this._a23378 -1 var b = this._b23379 -1 var c = this._c23380 -1 var d = this._d23381 -123382 -1 a = fnF(a, b, c, d, M[0], 0xd76aa478, 7)23383 -1 d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12)23384 -1 c = fnF(c, d, a, b, M[2], 0x242070db, 17)23385 -1 b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22)23386 -1 a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7)23387 -1 d = fnF(d, a, b, c, M[5], 0x4787c62a, 12)23388 -1 c = fnF(c, d, a, b, M[6], 0xa8304613, 17)23389 -1 b = fnF(b, c, d, a, M[7], 0xfd469501, 22)23390 -1 a = fnF(a, b, c, d, M[8], 0x698098d8, 7)23391 -1 d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12)23392 -1 c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17)23393 -1 b = fnF(b, c, d, a, M[11], 0x895cd7be, 22)23394 -1 a = fnF(a, b, c, d, M[12], 0x6b901122, 7)23395 -1 d = fnF(d, a, b, c, M[13], 0xfd987193, 12)23396 -1 c = fnF(c, d, a, b, M[14], 0xa679438e, 17)23397 -1 b = fnF(b, c, d, a, M[15], 0x49b40821, 22)23398 -123399 -1 a = fnG(a, b, c, d, M[1], 0xf61e2562, 5)23400 -1 d = fnG(d, a, b, c, M[6], 0xc040b340, 9)23401 -1 c = fnG(c, d, a, b, M[11], 0x265e5a51, 14)23402 -1 b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20)23403 -1 a = fnG(a, b, c, d, M[5], 0xd62f105d, 5)23404 -1 d = fnG(d, a, b, c, M[10], 0x02441453, 9)23405 -1 c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14)23406 -1 b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20)23407 -1 a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5)23408 -1 d = fnG(d, a, b, c, M[14], 0xc33707d6, 9)23409 -1 c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14)23410 -1 b = fnG(b, c, d, a, M[8], 0x455a14ed, 20)23411 -1 a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5)23412 -1 d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9)23413 -1 c = fnG(c, d, a, b, M[7], 0x676f02d9, 14)23414 -1 b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20)23415 -123416 -1 a = fnH(a, b, c, d, M[5], 0xfffa3942, 4)23417 -1 d = fnH(d, a, b, c, M[8], 0x8771f681, 11)23418 -1 c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16)23419 -1 b = fnH(b, c, d, a, M[14], 0xfde5380c, 23)23420 -1 a = fnH(a, b, c, d, M[1], 0xa4beea44, 4)23421 -1 d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11)23422 -1 c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16)23423 -1 b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23)23424 -1 a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4)23425 -1 d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11)23426 -1 c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16)23427 -1 b = fnH(b, c, d, a, M[6], 0x04881d05, 23)23428 -1 a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4)23429 -1 d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11)23430 -1 c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16)23431 -1 b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23)23432 -123433 -1 a = fnI(a, b, c, d, M[0], 0xf4292244, 6)23434 -1 d = fnI(d, a, b, c, M[7], 0x432aff97, 10)23435 -1 c = fnI(c, d, a, b, M[14], 0xab9423a7, 15)23436 -1 b = fnI(b, c, d, a, M[5], 0xfc93a039, 21)23437 -1 a = fnI(a, b, c, d, M[12], 0x655b59c3, 6)23438 -1 d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10)23439 -1 c = fnI(c, d, a, b, M[10], 0xffeff47d, 15)23440 -1 b = fnI(b, c, d, a, M[1], 0x85845dd1, 21)23441 -1 a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6)23442 -1 d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10)23443 -1 c = fnI(c, d, a, b, M[6], 0xa3014314, 15)23444 -1 b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21)23445 -1 a = fnI(a, b, c, d, M[4], 0xf7537e82, 6)23446 -1 d = fnI(d, a, b, c, M[11], 0xbd3af235, 10)23447 -1 c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15)23448 -1 b = fnI(b, c, d, a, M[9], 0xeb86d391, 21)23449 -123450 -1 this._a = (this._a + a) | 023451 -1 this._b = (this._b + b) | 023452 -1 this._c = (this._c + c) | 023453 -1 this._d = (this._d + d) | 023454 -1 }23455 -123456 -1 MD5.prototype._digest = function () {23457 -1 // create padding and handle blocks23458 -1 this._block[this._blockOffset++] = 0x8023459 -1 if (this._blockOffset > 56) {23460 -1 this._block.fill(0, this._blockOffset, 64)23461 -1 this._update()23462 -1 this._blockOffset = 023463 -1 }23464 -123465 -1 this._block.fill(0, this._blockOffset, 56)23466 -1 this._block.writeUInt32LE(this._length[0], 56)23467 -1 this._block.writeUInt32LE(this._length[1], 60)23468 -1 this._update()23469 -123470 -1 // produce result23471 -1 var buffer = Buffer.allocUnsafe(16)23472 -1 buffer.writeInt32LE(this._a, 0)23473 -1 buffer.writeInt32LE(this._b, 4)23474 -1 buffer.writeInt32LE(this._c, 8)23475 -1 buffer.writeInt32LE(this._d, 12)23476 -1 return buffer23477 -1 }23478 -123479 -1 function rotl (x, n) {23480 -1 return (x << n) | (x >>> (32 - n))23481 -1 }23482 -123483 -1 function fnF (a, b, c, d, m, k, s) {23484 -1 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 023485 -1 }23486 -123487 -1 function fnG (a, b, c, d, m, k, s) {23488 -1 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 023489 -1 }23490 -123491 -1 function fnH (a, b, c, d, m, k, s) {23492 -1 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 023493 -1 }23494 -123495 -1 function fnI (a, b, c, d, m, k, s) {23496 -1 return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 023497 -1 }23498 -123499 -1 module.exports = MD523500 -123501 -1 },{"hash-base":102,"inherits":132,"safe-buffer":160}],134:[function(require,module,exports){23502 -1 var bn = require('bn.js');23503 -1 var brorand = require('brorand');23504 -123505 -1 function MillerRabin(rand) {23506 -1 this.rand = rand || new brorand.Rand();23507 -1 }23508 -1 module.exports = MillerRabin;23509 -123510 -1 MillerRabin.create = function create(rand) {23511 -1 return new MillerRabin(rand);23512 -1 };23513 -123514 -1 MillerRabin.prototype._randbelow = function _randbelow(n) {23515 -1 var len = n.bitLength();23516 -1 var min_bytes = Math.ceil(len / 8);23517 -123518 -1 // Generage random bytes until a number less than n is found.23519 -1 // This ensures that 0..n-1 have an equal probability of being selected.23520 -1 do23521 -1 var a = new bn(this.rand.generate(min_bytes));23522 -1 while (a.cmp(n) >= 0);23523 -123524 -1 return a;23525 -1 };23526 -123527 -1 MillerRabin.prototype._randrange = function _randrange(start, stop) {23528 -1 // Generate a random number greater than or equal to start and less than stop.23529 -1 var size = stop.sub(start);23530 -1 return start.add(this._randbelow(size));23531 -1 };23532 -123533 -1 MillerRabin.prototype.test = function test(n, k, cb) {23534 -1 var len = n.bitLength();23535 -1 var red = bn.mont(n);23536 -1 var rone = new bn(1).toRed(red);23537 -123538 -1 if (!k)23539 -1 k = Math.max(1, (len / 48) | 0);23540 -123541 -1 // Find d and s, (n - 1) = (2 ^ s) * d;23542 -1 var n1 = n.subn(1);23543 -1 for (var s = 0; !n1.testn(s); s++) {}23544 -1 var d = n.shrn(s);23545 -123546 -1 var rn1 = n1.toRed(red);23547 -123548 -1 var prime = true;23549 -1 for (; k > 0; k--) {23550 -1 var a = this._randrange(new bn(2), n1);23551 -1 if (cb)23552 -1 cb(a);23553 -123554 -1 var x = a.toRed(red).redPow(d);23555 -1 if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)23556 -1 continue;23557 -123558 -1 for (var i = 1; i < s; i++) {23559 -1 x = x.redSqr();23560 -123561 -1 if (x.cmp(rone) === 0)23562 -1 return false;23563 -1 if (x.cmp(rn1) === 0)23564 -1 break;23565 -1 }23566 -123567 -1 if (i === s)23568 -1 return false;23569 -1 }23570 -123571 -1 return prime;23572 -1 };23573 -123574 -1 MillerRabin.prototype.getDivisor = function getDivisor(n, k) {23575 -1 var len = n.bitLength();23576 -1 var red = bn.mont(n);23577 -1 var rone = new bn(1).toRed(red);23578 -123579 -1 if (!k)23580 -1 k = Math.max(1, (len / 48) | 0);23581 -123582 -1 // Find d and s, (n - 1) = (2 ^ s) * d;23583 -1 var n1 = n.subn(1);23584 -1 for (var s = 0; !n1.testn(s); s++) {}23585 -1 var d = n.shrn(s);23586 -123587 -1 var rn1 = n1.toRed(red);23588 -123589 -1 for (; k > 0; k--) {23590 -1 var a = this._randrange(new bn(2), n1);23591 -123592 -1 var g = n.gcd(a);23593 -1 if (g.cmpn(1) !== 0)23594 -1 return g;23595 -123596 -1 var x = a.toRed(red).redPow(d);23597 -1 if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)23598 -1 continue;23599 -123600 -1 for (var i = 1; i < s; i++) {23601 -1 x = x.redSqr();23602 -123603 -1 if (x.cmp(rone) === 0)23604 -1 return x.fromRed().subn(1).gcd(n);23605 -1 if (x.cmp(rn1) === 0)23606 -1 break;23607 -1 }23608 -123609 -1 if (i === s) {23610 -1 x = x.redSqr();23611 -1 return x.fromRed().subn(1).gcd(n);23612 -1 }23613 -1 }23614 -123615 -1 return false;23616 -1 };23617 -123618 -1 },{"bn.js":135,"brorand":18}],135:[function(require,module,exports){23619 -1 arguments[4][15][0].apply(exports,arguments)23620 -1 },{"buffer":19,"dup":15}],136:[function(require,module,exports){23621 -1 module.exports = assert;23622 -123623 -1 function assert(val, msg) {23624 -1 if (!val)23625 -1 throw new Error(msg || 'Assertion failed');23626 -1 }23627 -123628 -1 assert.equal = function assertEqual(l, r, msg) {23629 -1 if (l != r)23630 -1 throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));23631 -1 };23632 -123633 -1 },{}],137:[function(require,module,exports){23634 -1 'use strict';23635 -123636 -1 var utils = exports;23637 -123638 -1 function toArray(msg, enc) {23639 -1 if (Array.isArray(msg))23640 -1 return msg.slice();23641 -1 if (!msg)23642 -1 return [];23643 -1 var res = [];23644 -1 if (typeof msg !== 'string') {23645 -1 for (var i = 0; i < msg.length; i++)23646 -1 res[i] = msg[i] | 0;23647 -1 return res;23648 -1 }23649 -1 if (enc === 'hex') {23650 -1 msg = msg.replace(/[^a-z0-9]+/ig, '');23651 -1 if (msg.length % 2 !== 0)23652 -1 msg = '0' + msg;23653 -1 for (var i = 0; i < msg.length; i += 2)23654 -1 res.push(parseInt(msg[i] + msg[i + 1], 16));23655 -1 } else {23656 -1 for (var i = 0; i < msg.length; i++) {23657 -1 var c = msg.charCodeAt(i);23658 -1 var hi = c >> 8;23659 -1 var lo = c & 0xff;23660 -1 if (hi)23661 -1 res.push(hi, lo);23662 -1 else23663 -1 res.push(lo);23664 -1 }23665 -1 }23666 -1 return res;23667 -1 }23668 -1 utils.toArray = toArray;23669 -123670 -1 function zero2(word) {23671 -1 if (word.length === 1)23672 -1 return '0' + word;23673 -1 else23674 -1 return word;23675 -1 }23676 -1 utils.zero2 = zero2;23677 -123678 -1 function toHex(msg) {23679 -1 var res = '';23680 -1 for (var i = 0; i < msg.length; i++)23681 -1 res += zero2(msg[i].toString(16));23682 -1 return res;23683 -1 }23684 -1 utils.toHex = toHex;23685 -123686 -1 utils.encode = function encode(arr, enc) {23687 -1 if (enc === 'hex')23688 -1 return toHex(arr);23689 -1 else23690 -1 return arr;23691 -1 };23692 -123693 -1 },{}],138:[function(require,module,exports){23694 -1 module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb",23695 -1 "2.16.840.1.101.3.4.1.2": "aes-128-cbc",23696 -1 "2.16.840.1.101.3.4.1.3": "aes-128-ofb",23697 -1 "2.16.840.1.101.3.4.1.4": "aes-128-cfb",23698 -1 "2.16.840.1.101.3.4.1.21": "aes-192-ecb",23699 -1 "2.16.840.1.101.3.4.1.22": "aes-192-cbc",23700 -1 "2.16.840.1.101.3.4.1.23": "aes-192-ofb",23701 -1 "2.16.840.1.101.3.4.1.24": "aes-192-cfb",23702 -1 "2.16.840.1.101.3.4.1.41": "aes-256-ecb",23703 -1 "2.16.840.1.101.3.4.1.42": "aes-256-cbc",23704 -1 "2.16.840.1.101.3.4.1.43": "aes-256-ofb",23705 -1 "2.16.840.1.101.3.4.1.44": "aes-256-cfb"23706 -1 }23707 -1 },{}],139:[function(require,module,exports){23708 -1 // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js23709 -1 // Fedor, you are amazing.23710 -1 'use strict'23711 -123712 -1 var asn1 = require('asn1.js')23713 -123714 -1 exports.certificate = require('./certificate')23715 -123716 -1 var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {23717 -1 this.seq().obj(23718 -1 this.key('version').int(),23719 -1 this.key('modulus').int(),23720 -1 this.key('publicExponent').int(),23721 -1 this.key('privateExponent').int(),23722 -1 this.key('prime1').int(),23723 -1 this.key('prime2').int(),23724 -1 this.key('exponent1').int(),23725 -1 this.key('exponent2').int(),23726 -1 this.key('coefficient').int()23727 -1 )23728 -1 })23729 -1 exports.RSAPrivateKey = RSAPrivateKey23730 -123731 -1 var RSAPublicKey = asn1.define('RSAPublicKey', function () {23732 -1 this.seq().obj(23733 -1 this.key('modulus').int(),23734 -1 this.key('publicExponent').int()23735 -1 )23736 -1 })23737 -1 exports.RSAPublicKey = RSAPublicKey23738 -123739 -1 var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {23740 -1 this.seq().obj(23741 -1 this.key('algorithm').use(AlgorithmIdentifier),23742 -1 this.key('subjectPublicKey').bitstr()23743 -1 )23744 -1 })23745 -1 exports.PublicKey = PublicKey23746 -123747 -1 var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {23748 -1 this.seq().obj(23749 -1 this.key('algorithm').objid(),23750 -1 this.key('none').null_().optional(),23751 -1 this.key('curve').objid().optional(),23752 -1 this.key('params').seq().obj(23753 -1 this.key('p').int(),23754 -1 this.key('q').int(),23755 -1 this.key('g').int()23756 -1 ).optional()23757 -1 )23758 -1 })23759 -123760 -1 var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {23761 -1 this.seq().obj(23762 -1 this.key('version').int(),23763 -1 this.key('algorithm').use(AlgorithmIdentifier),23764 -1 this.key('subjectPrivateKey').octstr()23765 -1 )23766 -1 })23767 -1 exports.PrivateKey = PrivateKeyInfo23768 -1 var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {23769 -1 this.seq().obj(23770 -1 this.key('algorithm').seq().obj(23771 -1 this.key('id').objid(),23772 -1 this.key('decrypt').seq().obj(23773 -1 this.key('kde').seq().obj(23774 -1 this.key('id').objid(),23775 -1 this.key('kdeparams').seq().obj(23776 -1 this.key('salt').octstr(),23777 -1 this.key('iters').int()23778 -1 )23779 -1 ),23780 -1 this.key('cipher').seq().obj(23781 -1 this.key('algo').objid(),23782 -1 this.key('iv').octstr()23783 -1 )23784 -1 )23785 -1 ),23786 -1 this.key('subjectPrivateKey').octstr()23787 -1 )23788 -1 })23789 -123790 -1 exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo23791 -123792 -1 var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {23793 -1 this.seq().obj(23794 -1 this.key('version').int(),23795 -1 this.key('p').int(),23796 -1 this.key('q').int(),23797 -1 this.key('g').int(),23798 -1 this.key('pub_key').int(),23799 -1 this.key('priv_key').int()23800 -1 )23801 -1 })23802 -1 exports.DSAPrivateKey = DSAPrivateKey23803 -123804 -1 exports.DSAparam = asn1.define('DSAparam', function () {23805 -1 this.int()23806 -1 })23807 -123808 -1 var ECPrivateKey = asn1.define('ECPrivateKey', function () {23809 -1 this.seq().obj(23810 -1 this.key('version').int(),23811 -1 this.key('privateKey').octstr(),23812 -1 this.key('parameters').optional().explicit(0).use(ECParameters),23813 -1 this.key('publicKey').optional().explicit(1).bitstr()23814 -1 )23815 -1 })23816 -1 exports.ECPrivateKey = ECPrivateKey23817 -123818 -1 var ECParameters = asn1.define('ECParameters', function () {23819 -1 this.choice({23820 -1 namedCurve: this.objid()23821 -1 })23822 -1 })23823 -123824 -1 exports.signature = asn1.define('signature', function () {23825 -1 this.seq().obj(23826 -1 this.key('r').int(),23827 -1 this.key('s').int()23828 -1 )23829 -1 })23830 -123831 -1 },{"./certificate":140,"asn1.js":1}],140:[function(require,module,exports){23832 -1 // from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js23833 -1 // thanks to @Rantanen23834 -123835 -1 'use strict'23836 -123837 -1 var asn = require('asn1.js')23838 -123839 -1 var Time = asn.define('Time', function () {23840 -1 this.choice({23841 -1 utcTime: this.utctime(),23842 -1 generalTime: this.gentime()23843 -1 })23844 -1 })23845 -123846 -1 var AttributeTypeValue = asn.define('AttributeTypeValue', function () {23847 -1 this.seq().obj(23848 -1 this.key('type').objid(),23849 -1 this.key('value').any()23850 -1 )23851 -1 })23852 -123853 -1 var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () {23854 -1 this.seq().obj(23855 -1 this.key('algorithm').objid(),23856 -1 this.key('parameters').optional(),23857 -1 this.key('curve').objid().optional()23858 -1 )23859 -1 })23860 -123861 -1 var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () {23862 -1 this.seq().obj(23863 -1 this.key('algorithm').use(AlgorithmIdentifier),23864 -1 this.key('subjectPublicKey').bitstr()23865 -1 )23866 -1 })23867 -123868 -1 var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () {23869 -1 this.setof(AttributeTypeValue)23870 -1 })23871 -123872 -1 var RDNSequence = asn.define('RDNSequence', function () {23873 -1 this.seqof(RelativeDistinguishedName)23874 -1 })23875 -123876 -1 var Name = asn.define('Name', function () {23877 -1 this.choice({23878 -1 rdnSequence: this.use(RDNSequence)23879 -1 })23880 -1 })23881 -123882 -1 var Validity = asn.define('Validity', function () {23883 -1 this.seq().obj(23884 -1 this.key('notBefore').use(Time),23885 -1 this.key('notAfter').use(Time)23886 -1 )23887 -1 })23888 -123889 -1 var Extension = asn.define('Extension', function () {23890 -1 this.seq().obj(23891 -1 this.key('extnID').objid(),23892 -1 this.key('critical').bool().def(false),23893 -1 this.key('extnValue').octstr()23894 -1 )23895 -1 })23896 -123897 -1 var TBSCertificate = asn.define('TBSCertificate', function () {23898 -1 this.seq().obj(23899 -1 this.key('version').explicit(0).int().optional(),23900 -1 this.key('serialNumber').int(),23901 -1 this.key('signature').use(AlgorithmIdentifier),23902 -1 this.key('issuer').use(Name),23903 -1 this.key('validity').use(Validity),23904 -1 this.key('subject').use(Name),23905 -1 this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo),23906 -1 this.key('issuerUniqueID').implicit(1).bitstr().optional(),23907 -1 this.key('subjectUniqueID').implicit(2).bitstr().optional(),23908 -1 this.key('extensions').explicit(3).seqof(Extension).optional()23909 -1 )23910 -1 })23911 -123912 -1 var X509Certificate = asn.define('X509Certificate', function () {23913 -1 this.seq().obj(23914 -1 this.key('tbsCertificate').use(TBSCertificate),23915 -1 this.key('signatureAlgorithm').use(AlgorithmIdentifier),23916 -1 this.key('signatureValue').bitstr()23917 -1 )23918 -1 })23919 -123920 -1 module.exports = X509Certificate23921 -123922 -1 },{"asn1.js":1}],141:[function(require,module,exports){23923 -1 // adapted from https://github.com/apatil/pemstrip23924 -1 var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m23925 -1 var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m23926 -1 var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m23927 -1 var evp = require('evp_bytestokey')23928 -1 var ciphers = require('browserify-aes')23929 -1 var Buffer = require('safe-buffer').Buffer23930 -1 module.exports = function (okey, password) {23931 -1 var key = okey.toString()23932 -1 var match = key.match(findProc)23933 -1 var decrypted23934 -1 if (!match) {23935 -1 var match2 = key.match(fullRegex)23936 -1 decrypted = Buffer.from(match2[2].replace(/[\r\n]/g, ''), 'base64')23937 -1 } else {23938 -1 var suite = 'aes' + match[1]23939 -1 var iv = Buffer.from(match[2], 'hex')23940 -1 var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64')23941 -1 var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key23942 -1 var out = []23943 -1 var cipher = ciphers.createDecipheriv(suite, cipherKey, iv)23944 -1 out.push(cipher.update(cipherText))23945 -1 out.push(cipher.final())23946 -1 decrypted = Buffer.concat(out)23947 -1 }23948 -1 var tag = key.match(startRegex)[1]23949 -1 return {23950 -1 tag: tag,23951 -1 data: decrypted23952 -1 }23953 -1 }23954 -123955 -1 },{"browserify-aes":22,"evp_bytestokey":101,"safe-buffer":160}],142:[function(require,module,exports){23956 -1 var asn1 = require('./asn1')23957 -1 var aesid = require('./aesid.json')23958 -1 var fixProc = require('./fixProc')23959 -1 var ciphers = require('browserify-aes')23960 -1 var compat = require('pbkdf2')23961 -1 var Buffer = require('safe-buffer').Buffer23962 -1 module.exports = parseKeys23963 -123964 -1 function parseKeys (buffer) {23965 -1 var password23966 -1 if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) {23967 -1 password = buffer.passphrase23968 -1 buffer = buffer.key23969 -1 }23970 -1 if (typeof buffer === 'string') {23971 -1 buffer = Buffer.from(buffer)23972 -1 }23973 -123974 -1 var stripped = fixProc(buffer, password)23975 -123976 -1 var type = stripped.tag23977 -1 var data = stripped.data23978 -1 var subtype, ndata23979 -1 switch (type) {23980 -1 case 'CERTIFICATE':23981 -1 ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo23982 -1 // falls through23983 -1 case 'PUBLIC KEY':23984 -1 if (!ndata) {23985 -1 ndata = asn1.PublicKey.decode(data, 'der')23986 -1 }23987 -1 subtype = ndata.algorithm.algorithm.join('.')23988 -1 switch (subtype) {23989 -1 case '1.2.840.113549.1.1.1':23990 -1 return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der')23991 -1 case '1.2.840.10045.2.1':23992 -1 ndata.subjectPrivateKey = ndata.subjectPublicKey23993 -1 return {23994 -1 type: 'ec',23995 -1 data: ndata23996 -1 }23997 -1 case '1.2.840.10040.4.1':23998 -1 ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der')23999 -1 return {24000 -1 type: 'dsa',24001 -1 data: ndata.algorithm.params24002 -1 }24003 -1 default: throw new Error('unknown key id ' + subtype)24004 -1 }24005 -1 // throw new Error('unknown key type ' + type)24006 -1 case 'ENCRYPTED PRIVATE KEY':24007 -1 data = asn1.EncryptedPrivateKey.decode(data, 'der')24008 -1 data = decrypt(data, password)24009 -1 // falls through24010 -1 case 'PRIVATE KEY':24011 -1 ndata = asn1.PrivateKey.decode(data, 'der')24012 -1 subtype = ndata.algorithm.algorithm.join('.')24013 -1 switch (subtype) {24014 -1 case '1.2.840.113549.1.1.1':24015 -1 return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der')24016 -1 case '1.2.840.10045.2.1':24017 -1 return {24018 -1 curve: ndata.algorithm.curve,24019 -1 privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey24020 -1 }24021 -1 case '1.2.840.10040.4.1':24022 -1 ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der')24023 -1 return {24024 -1 type: 'dsa',24025 -1 params: ndata.algorithm.params24026 -1 }24027 -1 default: throw new Error('unknown key id ' + subtype)24028 -1 }24029 -1 // throw new Error('unknown key type ' + type)24030 -1 case 'RSA PUBLIC KEY':24031 -1 return asn1.RSAPublicKey.decode(data, 'der')24032 -1 case 'RSA PRIVATE KEY':24033 -1 return asn1.RSAPrivateKey.decode(data, 'der')24034 -1 case 'DSA PRIVATE KEY':24035 -1 return {24036 -1 type: 'dsa',24037 -1 params: asn1.DSAPrivateKey.decode(data, 'der')24038 -1 }24039 -1 case 'EC PRIVATE KEY':24040 -1 data = asn1.ECPrivateKey.decode(data, 'der')24041 -1 return {24042 -1 curve: data.parameters.value,24043 -1 privateKey: data.privateKey24044 -1 }24045 -1 default: throw new Error('unknown key type ' + type)24046 -1 }24047 -1 }24048 -1 parseKeys.signature = asn1.signature24049 -1 function decrypt (data, password) {24050 -1 var salt = data.algorithm.decrypt.kde.kdeparams.salt24051 -1 var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10)24052 -1 var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')]24053 -1 var iv = data.algorithm.decrypt.cipher.iv24054 -1 var cipherText = data.subjectPrivateKey24055 -1 var keylen = parseInt(algo.split('-')[1], 10) / 824056 -1 var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1')24057 -1 var cipher = ciphers.createDecipheriv(algo, key, iv)24058 -1 var out = []24059 -1 out.push(cipher.update(cipherText))24060 -1 out.push(cipher.final())24061 -1 return Buffer.concat(out)24062 -1 }24063 -124064 -1 },{"./aesid.json":138,"./asn1":139,"./fixProc":141,"browserify-aes":22,"pbkdf2":143,"safe-buffer":160}],143:[function(require,module,exports){24065 -1 exports.pbkdf2 = require('./lib/async')24066 -1 exports.pbkdf2Sync = require('./lib/sync')24067 -124068 -1 },{"./lib/async":144,"./lib/sync":147}],144:[function(require,module,exports){24069 -1 (function (process,global){(function (){24070 -1 var Buffer = require('safe-buffer').Buffer24071 -124072 -1 var checkParameters = require('./precondition')24073 -1 var defaultEncoding = require('./default-encoding')24074 -1 var sync = require('./sync')24075 -1 var toBuffer = require('./to-buffer')24076 -124077 -1 var ZERO_BUF24078 -1 var subtle = global.crypto && global.crypto.subtle24079 -1 var toBrowser = {24080 -1 sha: 'SHA-1',24081 -1 'sha-1': 'SHA-1',24082 -1 sha1: 'SHA-1',24083 -1 sha256: 'SHA-256',24084 -1 'sha-256': 'SHA-256',24085 -1 sha384: 'SHA-384',24086 -1 'sha-384': 'SHA-384',24087 -1 'sha-512': 'SHA-512',24088 -1 sha512: 'SHA-512'24089 -1 }24090 -1 var checks = []24091 -1 function checkNative (algo) {24092 -1 if (global.process && !global.process.browser) {24093 -1 return Promise.resolve(false)24094 -1 }24095 -1 if (!subtle || !subtle.importKey || !subtle.deriveBits) {24096 -1 return Promise.resolve(false)24097 -1 }24098 -1 if (checks[algo] !== undefined) {24099 -1 return checks[algo]24100 -1 }24101 -1 ZERO_BUF = ZERO_BUF || Buffer.alloc(8)24102 -1 var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo)24103 -1 .then(function () {24104 -1 return true24105 -1 }).catch(function () {24106 -1 return false24107 -1 })24108 -1 checks[algo] = prom24109 -1 return prom24110 -1 }24111 -124112 -1 function browserPbkdf2 (password, salt, iterations, length, algo) {24113 -1 return subtle.importKey(24114 -1 'raw', password, { name: 'PBKDF2' }, false, ['deriveBits']24115 -1 ).then(function (key) {24116 -1 return subtle.deriveBits({24117 -1 name: 'PBKDF2',24118 -1 salt: salt,24119 -1 iterations: iterations,24120 -1 hash: {24121 -1 name: algo24122 -1 }24123 -1 }, key, length << 3)24124 -1 }).then(function (res) {24125 -1 return Buffer.from(res)24126 -1 })24127 -1 }24128 -124129 -1 function resolvePromise (promise, callback) {24130 -1 promise.then(function (out) {24131 -1 process.nextTick(function () {24132 -1 callback(null, out)24133 -1 })24134 -1 }, function (e) {24135 -1 process.nextTick(function () {24136 -1 callback(e)24137 -1 })24138 -1 })24139 -1 }24140 -1 module.exports = function (password, salt, iterations, keylen, digest, callback) {24141 -1 if (typeof digest === 'function') {24142 -1 callback = digest24143 -1 digest = undefined24144 -1 }24145 -124146 -1 digest = digest || 'sha1'24147 -1 var algo = toBrowser[digest.toLowerCase()]24148 -124149 -1 if (!algo || typeof global.Promise !== 'function') {24150 -1 return process.nextTick(function () {24151 -1 var out24152 -1 try {24153 -1 out = sync(password, salt, iterations, keylen, digest)24154 -1 } catch (e) {24155 -1 return callback(e)24156 -1 }24157 -1 callback(null, out)24158 -1 })24159 -1 }24160 -124161 -1 checkParameters(iterations, keylen)24162 -1 password = toBuffer(password, defaultEncoding, 'Password')24163 -1 salt = toBuffer(salt, defaultEncoding, 'Salt')24164 -1 if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')24165 -124166 -1 resolvePromise(checkNative(algo).then(function (resp) {24167 -1 if (resp) return browserPbkdf2(password, salt, iterations, keylen, algo)24168 -124169 -1 return sync(password, salt, iterations, keylen, digest)24170 -1 }), callback)24171 -1 }24172 -124173 -1 }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})24174 -1 },{"./default-encoding":145,"./precondition":146,"./sync":147,"./to-buffer":148,"_process":149,"safe-buffer":160}],145:[function(require,module,exports){24175 -1 (function (process){(function (){24176 -1 var defaultEncoding24177 -1 /* istanbul ignore next */24178 -1 if (process.browser) {24179 -1 defaultEncoding = 'utf-8'24180 -1 } else if (process.version) {24181 -1 var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10)24182 -124183 -1 defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary'24184 -1 } else {24185 -1 defaultEncoding = 'utf-8'24186 -1 }24187 -1 module.exports = defaultEncoding24188 -124189 -1 }).call(this)}).call(this,require('_process'))24190 -1 },{"_process":149}],146:[function(require,module,exports){24191 -1 var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs24192 -124193 -1 module.exports = function (iterations, keylen) {24194 -1 if (typeof iterations !== 'number') {24195 -1 throw new TypeError('Iterations not a number')24196 -1 }24197 -124198 -1 if (iterations < 0) {24199 -1 throw new TypeError('Bad iterations')24200 -1 }24201 -124202 -1 if (typeof keylen !== 'number') {24203 -1 throw new TypeError('Key length not a number')24204 -1 }24205 -124206 -1 if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */24207 -1 throw new TypeError('Bad key length')24208 -1 }24209 -1 }24210 -124211 -1 },{}],147:[function(require,module,exports){24212 -1 var md5 = require('create-hash/md5')24213 -1 var RIPEMD160 = require('ripemd160')24214 -1 var sha = require('sha.js')24215 -1 var Buffer = require('safe-buffer').Buffer24216 -124217 -1 var checkParameters = require('./precondition')24218 -1 var defaultEncoding = require('./default-encoding')24219 -1 var toBuffer = require('./to-buffer')24220 -124221 -1 var ZEROS = Buffer.alloc(128)24222 -1 var sizes = {24223 -1 md5: 16,24224 -1 sha1: 20,24225 -1 sha224: 28,24226 -1 sha256: 32,24227 -1 sha384: 48,24228 -1 sha512: 64,24229 -1 rmd160: 20,24230 -1 ripemd160: 2024231 -1 }24232 -124233 -1 function Hmac (alg, key, saltLen) {24234 -1 var hash = getDigest(alg)24235 -1 var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 6424236 -124237 -1 if (key.length > blocksize) {24238 -1 key = hash(key)24239 -1 } else if (key.length < blocksize) {24240 -1 key = Buffer.concat([key, ZEROS], blocksize)24241 -1 }24242 -124243 -1 var ipad = Buffer.allocUnsafe(blocksize + sizes[alg])24244 -1 var opad = Buffer.allocUnsafe(blocksize + sizes[alg])24245 -1 for (var i = 0; i < blocksize; i++) {24246 -1 ipad[i] = key[i] ^ 0x3624247 -1 opad[i] = key[i] ^ 0x5C24248 -1 }24249 -124250 -1 var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4)24251 -1 ipad.copy(ipad1, 0, 0, blocksize)24252 -1 this.ipad1 = ipad124253 -1 this.ipad2 = ipad24254 -1 this.opad = opad24255 -1 this.alg = alg24256 -1 this.blocksize = blocksize24257 -1 this.hash = hash24258 -1 this.size = sizes[alg]24259 -1 }24260 -124261 -1 Hmac.prototype.run = function (data, ipad) {24262 -1 data.copy(ipad, this.blocksize)24263 -1 var h = this.hash(ipad)24264 -1 h.copy(this.opad, this.blocksize)24265 -1 return this.hash(this.opad)24266 -1 }24267 -124268 -1 function getDigest (alg) {24269 -1 function shaFunc (data) {24270 -1 return sha(alg).update(data).digest()24271 -1 }24272 -1 function rmd160Func (data) {24273 -1 return new RIPEMD160().update(data).digest()24274 -1 }24275 -124276 -1 if (alg === 'rmd160' || alg === 'ripemd160') return rmd160Func24277 -1 if (alg === 'md5') return md524278 -1 return shaFunc24279 -1 }24280 -124281 -1 function pbkdf2 (password, salt, iterations, keylen, digest) {24282 -1 checkParameters(iterations, keylen)24283 -1 password = toBuffer(password, defaultEncoding, 'Password')24284 -1 salt = toBuffer(salt, defaultEncoding, 'Salt')24285 -124286 -1 digest = digest || 'sha1'24287 -124288 -1 var hmac = new Hmac(digest, password, salt.length)24289 -124290 -1 var DK = Buffer.allocUnsafe(keylen)24291 -1 var block1 = Buffer.allocUnsafe(salt.length + 4)24292 -1 salt.copy(block1, 0, 0, salt.length)24293 -124294 -1 var destPos = 024295 -1 var hLen = sizes[digest]24296 -1 var l = Math.ceil(keylen / hLen)24297 -124298 -1 for (var i = 1; i <= l; i++) {24299 -1 block1.writeUInt32BE(i, salt.length)24300 -124301 -1 var T = hmac.run(block1, hmac.ipad1)24302 -1 var U = T24303 -124304 -1 for (var j = 1; j < iterations; j++) {24305 -1 U = hmac.run(U, hmac.ipad2)24306 -1 for (var k = 0; k < hLen; k++) T[k] ^= U[k]24307 -1 }24308 -124309 -1 T.copy(DK, destPos)24310 -1 destPos += hLen24311 -1 }24312 -124313 -1 return DK24314 -1 }24315 -124316 -1 module.exports = pbkdf224317 -124318 -1 },{"./default-encoding":145,"./precondition":146,"./to-buffer":148,"create-hash/md5":68,"ripemd160":159,"safe-buffer":160,"sha.js":163}],148:[function(require,module,exports){24319 -1 var Buffer = require('safe-buffer').Buffer24320 -124321 -1 module.exports = function (thing, encoding, name) {24322 -1 if (Buffer.isBuffer(thing)) {24323 -1 return thing24324 -1 } else if (typeof thing === 'string') {24325 -1 return Buffer.from(thing, encoding)24326 -1 } else if (ArrayBuffer.isView(thing)) {24327 -1 return Buffer.from(thing.buffer)24328 -1 } else {24329 -1 throw new TypeError(name + ' must be a string, a Buffer, a typed array or a DataView')24330 -1 }24331 -1 }24332 -124333 -1 },{"safe-buffer":160}],149:[function(require,module,exports){24334 -1 // shim for using process in browser24335 -1 var process = module.exports = {};24336 -124337 -1 // cached from whatever global is present so that test runners that stub it24338 -1 // don't break things. But we need to wrap it in a try catch in case it is24339 -1 // wrapped in strict mode code which doesn't define any globals. It's inside a24340 -1 // function because try/catches deoptimize in certain engines.24341 -124342 -1 var cachedSetTimeout;24343 -1 var cachedClearTimeout;24344 -124345 -1 function defaultSetTimout() {24346 -1 throw new Error('setTimeout has not been defined');24347 -1 }24348 -1 function defaultClearTimeout () {24349 -1 throw new Error('clearTimeout has not been defined');24350 -1 }24351 -1 (function () {24352 -1 try {24353 -1 if (typeof setTimeout === 'function') {24354 -1 cachedSetTimeout = setTimeout;24355 -1 } else {24356 -1 cachedSetTimeout = defaultSetTimout;24357 -1 }24358 -1 } catch (e) {24359 -1 cachedSetTimeout = defaultSetTimout;24360 -1 }24361 -1 try {24362 -1 if (typeof clearTimeout === 'function') {24363 -1 cachedClearTimeout = clearTimeout;24364 -1 } else {24365 -1 cachedClearTimeout = defaultClearTimeout;24366 -1 }24367 -1 } catch (e) {24368 -1 cachedClearTimeout = defaultClearTimeout;24369 -1 }24370 -1 } ())24371 -1 function runTimeout(fun) {24372 -1 if (cachedSetTimeout === setTimeout) {24373 -1 //normal enviroments in sane situations24374 -1 return setTimeout(fun, 0);24375 -1 }24376 -1 // if setTimeout wasn't available but was latter defined24377 -1 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {24378 -1 cachedSetTimeout = setTimeout;24379 -1 return setTimeout(fun, 0);24380 -1 }24381 -1 try {24382 -1 // when when somebody has screwed with setTimeout but no I.E. maddness24383 -1 return cachedSetTimeout(fun, 0);24384 -1 } catch(e){24385 -1 try {24386 -1 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally24387 -1 return cachedSetTimeout.call(null, fun, 0);24388 -1 } catch(e){24389 -1 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error24390 -1 return cachedSetTimeout.call(this, fun, 0);24391 -1 }24392 -1 }24393 -124394 -124395 -1 }24396 -1 function runClearTimeout(marker) {24397 -1 if (cachedClearTimeout === clearTimeout) {24398 -1 //normal enviroments in sane situations24399 -1 return clearTimeout(marker);24400 -1 }24401 -1 // if clearTimeout wasn't available but was latter defined24402 -1 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {24403 -1 cachedClearTimeout = clearTimeout;24404 -1 return clearTimeout(marker);24405 -1 }24406 -1 try {24407 -1 // when when somebody has screwed with setTimeout but no I.E. maddness24408 -1 return cachedClearTimeout(marker);24409 -1 } catch (e){24410 -1 try {24411 -1 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally24412 -1 return cachedClearTimeout.call(null, marker);24413 -1 } catch (e){24414 -1 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.24415 -1 // Some versions of I.E. have different rules for clearTimeout vs setTimeout24416 -1 return cachedClearTimeout.call(this, marker);24417 -1 }24418 -1 }24419 -124420 -124421 -124422 -1 }24423 -1 var queue = [];24424 -1 var draining = false;24425 -1 var currentQueue;24426 -1 var queueIndex = -1;24427 -124428 -1 function cleanUpNextTick() {24429 -1 if (!draining || !currentQueue) {24430 -1 return;24431 -1 }24432 -1 draining = false;24433 -1 if (currentQueue.length) {24434 -1 queue = currentQueue.concat(queue);24435 -1 } else {24436 -1 queueIndex = -1;24437 -1 }24438 -1 if (queue.length) {24439 -1 drainQueue();24440 -1 }24441 -1 }24442 -124443 -1 function drainQueue() {24444 -1 if (draining) {24445 -1 return;24446 -1 }24447 -1 var timeout = runTimeout(cleanUpNextTick);24448 -1 draining = true;24449 -124450 -1 var len = queue.length;24451 -1 while(len) {24452 -1 currentQueue = queue;24453 -1 queue = [];24454 -1 while (++queueIndex < len) {24455 -1 if (currentQueue) {24456 -1 currentQueue[queueIndex].run();24457 -1 }24458 -1 }24459 -1 queueIndex = -1;24460 -1 len = queue.length;24461 -1 }24462 -1 currentQueue = null;24463 -1 draining = false;24464 -1 runClearTimeout(timeout);24465 -1 }24466 -124467 -1 process.nextTick = function (fun) {24468 -1 var args = new Array(arguments.length - 1);24469 -1 if (arguments.length > 1) {24470 -1 for (var i = 1; i < arguments.length; i++) {24471 -1 args[i - 1] = arguments[i];24472 -1 }24473 -1 }24474 -1 queue.push(new Item(fun, args));24475 -1 if (queue.length === 1 && !draining) {24476 -1 runTimeout(drainQueue);24477 -1 }24478 -1 };24479 -124480 -1 // v8 likes predictible objects24481 -1 function Item(fun, array) {24482 -1 this.fun = fun;24483 -1 this.array = array;24484 -1 }24485 -1 Item.prototype.run = function () {24486 -1 this.fun.apply(null, this.array);24487 -1 };24488 -1 process.title = 'browser';24489 -1 process.browser = true;24490 -1 process.env = {};24491 -1 process.argv = [];24492 -1 process.version = ''; // empty string to avoid regexp issues24493 -1 process.versions = {};24494 -124495 -1 function noop() {}24496 -124497 -1 process.on = noop;24498 -1 process.addListener = noop;24499 -1 process.once = noop;24500 -1 process.off = noop;24501 -1 process.removeListener = noop;24502 -1 process.removeAllListeners = noop;24503 -1 process.emit = noop;24504 -1 process.prependListener = noop;24505 -1 process.prependOnceListener = noop;24506 -124507 -1 process.listeners = function (name) { return [] }24508 -124509 -1 process.binding = function (name) {24510 -1 throw new Error('process.binding is not supported');24511 -1 };24512 -124513 -1 process.cwd = function () { return '/' };24514 -1 process.chdir = function (dir) {24515 -1 throw new Error('process.chdir is not supported');24516 -1 };24517 -1 process.umask = function() { return 0; };24518 -124519 -1 },{}],150:[function(require,module,exports){24520 -1 exports.publicEncrypt = require('./publicEncrypt')24521 -1 exports.privateDecrypt = require('./privateDecrypt')24522 -124523 -1 exports.privateEncrypt = function privateEncrypt (key, buf) {24524 -1 return exports.publicEncrypt(key, buf, true)24525 -1 }24526 -124527 -1 exports.publicDecrypt = function publicDecrypt (key, buf) {24528 -1 return exports.privateDecrypt(key, buf, true)24529 -1 }24530 -124531 -1 },{"./privateDecrypt":153,"./publicEncrypt":154}],151:[function(require,module,exports){24532 -1 var createHash = require('create-hash')24533 -1 var Buffer = require('safe-buffer').Buffer24534 -124535 -1 module.exports = function (seed, len) {24536 -1 var t = Buffer.alloc(0)24537 -1 var i = 024538 -1 var c24539 -1 while (t.length < len) {24540 -1 c = i2ops(i++)24541 -1 t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()])24542 -1 }24543 -1 return t.slice(0, len)24544 -1 }24545 -124546 -1 function i2ops (c) {24547 -1 var out = Buffer.allocUnsafe(4)24548 -1 out.writeUInt32BE(c, 0)24549 -1 return out24550 -1 }24551 -124552 -1 },{"create-hash":67,"safe-buffer":160}],152:[function(require,module,exports){24553 -1 arguments[4][15][0].apply(exports,arguments)24554 -1 },{"buffer":19,"dup":15}],153:[function(require,module,exports){24555 -1 var parseKeys = require('parse-asn1')24556 -1 var mgf = require('./mgf')24557 -1 var xor = require('./xor')24558 -1 var BN = require('bn.js')24559 -1 var crt = require('browserify-rsa')24560 -1 var createHash = require('create-hash')24561 -1 var withPublic = require('./withPublic')24562 -1 var Buffer = require('safe-buffer').Buffer24563 -124564 -1 module.exports = function privateDecrypt (privateKey, enc, reverse) {24565 -1 var padding24566 -1 if (privateKey.padding) {24567 -1 padding = privateKey.padding24568 -1 } else if (reverse) {24569 -1 padding = 124570 -1 } else {24571 -1 padding = 424572 -1 }24573 -124574 -1 var key = parseKeys(privateKey)24575 -1 var k = key.modulus.byteLength()24576 -1 if (enc.length > k || new BN(enc).cmp(key.modulus) >= 0) {24577 -1 throw new Error('decryption error')24578 -1 }24579 -1 var msg24580 -1 if (reverse) {24581 -1 msg = withPublic(new BN(enc), key)24582 -1 } else {24583 -1 msg = crt(enc, key)24584 -1 }24585 -1 var zBuffer = Buffer.alloc(k - msg.length)24586 -1 msg = Buffer.concat([zBuffer, msg], k)24587 -1 if (padding === 4) {24588 -1 return oaep(key, msg)24589 -1 } else if (padding === 1) {24590 -1 return pkcs1(key, msg, reverse)24591 -1 } else if (padding === 3) {24592 -1 return msg24593 -1 } else {24594 -1 throw new Error('unknown padding')24595 -1 }24596 -1 }24597 -124598 -1 function oaep (key, msg) {24599 -1 var k = key.modulus.byteLength()24600 -1 var iHash = createHash('sha1').update(Buffer.alloc(0)).digest()24601 -1 var hLen = iHash.length24602 -1 if (msg[0] !== 0) {24603 -1 throw new Error('decryption error')24604 -1 }24605 -1 var maskedSeed = msg.slice(1, hLen + 1)24606 -1 var maskedDb = msg.slice(hLen + 1)24607 -1 var seed = xor(maskedSeed, mgf(maskedDb, hLen))24608 -1 var db = xor(maskedDb, mgf(seed, k - hLen - 1))24609 -1 if (compare(iHash, db.slice(0, hLen))) {24610 -1 throw new Error('decryption error')24611 -1 }24612 -1 var i = hLen24613 -1 while (db[i] === 0) {24614 -1 i++24615 -1 }24616 -1 if (db[i++] !== 1) {24617 -1 throw new Error('decryption error')24618 -1 }24619 -1 return db.slice(i)24620 -1 }24621 -124622 -1 function pkcs1 (key, msg, reverse) {24623 -1 var p1 = msg.slice(0, 2)24624 -1 var i = 224625 -1 var status = 024626 -1 while (msg[i++] !== 0) {24627 -1 if (i >= msg.length) {24628 -1 status++24629 -1 break24630 -1 }24631 -1 }24632 -1 var ps = msg.slice(2, i - 1)24633 -124634 -1 if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)) {24635 -1 status++24636 -1 }24637 -1 if (ps.length < 8) {24638 -1 status++24639 -1 }24640 -1 if (status) {24641 -1 throw new Error('decryption error')24642 -1 }24643 -1 return msg.slice(i)24644 -1 }24645 -1 function compare (a, b) {24646 -1 a = Buffer.from(a)24647 -1 b = Buffer.from(b)24648 -1 var dif = 024649 -1 var len = a.length24650 -1 if (a.length !== b.length) {24651 -1 dif++24652 -1 len = Math.min(a.length, b.length)24653 -1 }24654 -1 var i = -124655 -1 while (++i < len) {24656 -1 dif += (a[i] ^ b[i])24657 -1 }24658 -1 return dif24659 -1 }24660 -124661 -1 },{"./mgf":151,"./withPublic":155,"./xor":156,"bn.js":152,"browserify-rsa":40,"create-hash":67,"parse-asn1":142,"safe-buffer":160}],154:[function(require,module,exports){24662 -1 var parseKeys = require('parse-asn1')24663 -1 var randomBytes = require('randombytes')24664 -1 var createHash = require('create-hash')24665 -1 var mgf = require('./mgf')24666 -1 var xor = require('./xor')24667 -1 var BN = require('bn.js')24668 -1 var withPublic = require('./withPublic')24669 -1 var crt = require('browserify-rsa')24670 -1 var Buffer = require('safe-buffer').Buffer24671 -124672 -1 module.exports = function publicEncrypt (publicKey, msg, reverse) {24673 -1 var padding24674 -1 if (publicKey.padding) {24675 -1 padding = publicKey.padding24676 -1 } else if (reverse) {24677 -1 padding = 124678 -1 } else {24679 -1 padding = 424680 -1 }24681 -1 var key = parseKeys(publicKey)24682 -1 var paddedMsg24683 -1 if (padding === 4) {24684 -1 paddedMsg = oaep(key, msg)24685 -1 } else if (padding === 1) {24686 -1 paddedMsg = pkcs1(key, msg, reverse)24687 -1 } else if (padding === 3) {24688 -1 paddedMsg = new BN(msg)24689 -1 if (paddedMsg.cmp(key.modulus) >= 0) {24690 -1 throw new Error('data too long for modulus')24691 -1 }24692 -1 } else {24693 -1 throw new Error('unknown padding')24694 -1 }24695 -1 if (reverse) {24696 -1 return crt(paddedMsg, key)24697 -1 } else {24698 -1 return withPublic(paddedMsg, key)24699 -1 }24700 -1 }24701 -124702 -1 function oaep (key, msg) {24703 -1 var k = key.modulus.byteLength()24704 -1 var mLen = msg.length24705 -1 var iHash = createHash('sha1').update(Buffer.alloc(0)).digest()24706 -1 var hLen = iHash.length24707 -1 var hLen2 = 2 * hLen24708 -1 if (mLen > k - hLen2 - 2) {24709 -1 throw new Error('message too long')24710 -1 }24711 -1 var ps = Buffer.alloc(k - mLen - hLen2 - 2)24712 -1 var dblen = k - hLen - 124713 -1 var seed = randomBytes(hLen)24714 -1 var maskedDb = xor(Buffer.concat([iHash, ps, Buffer.alloc(1, 1), msg], dblen), mgf(seed, dblen))24715 -1 var maskedSeed = xor(seed, mgf(maskedDb, hLen))24716 -1 return new BN(Buffer.concat([Buffer.alloc(1), maskedSeed, maskedDb], k))24717 -1 }24718 -1 function pkcs1 (key, msg, reverse) {24719 -1 var mLen = msg.length24720 -1 var k = key.modulus.byteLength()24721 -1 if (mLen > k - 11) {24722 -1 throw new Error('message too long')24723 -1 }24724 -1 var ps24725 -1 if (reverse) {24726 -1 ps = Buffer.alloc(k - mLen - 3, 0xff)24727 -1 } else {24728 -1 ps = nonZero(k - mLen - 3)24729 -1 }24730 -1 return new BN(Buffer.concat([Buffer.from([0, reverse ? 1 : 2]), ps, Buffer.alloc(1), msg], k))24731 -1 }24732 -1 function nonZero (len) {24733 -1 var out = Buffer.allocUnsafe(len)24734 -1 var i = 024735 -1 var cache = randomBytes(len * 2)24736 -1 var cur = 024737 -1 var num24738 -1 while (i < len) {24739 -1 if (cur === cache.length) {24740 -1 cache = randomBytes(len * 2)24741 -1 cur = 024742 -1 }24743 -1 num = cache[cur++]24744 -1 if (num) {24745 -1 out[i++] = num24746 -1 }24747 -1 }24748 -1 return out24749 -1 }24750 -124751 -1 },{"./mgf":151,"./withPublic":155,"./xor":156,"bn.js":152,"browserify-rsa":40,"create-hash":67,"parse-asn1":142,"randombytes":157,"safe-buffer":160}],155:[function(require,module,exports){24752 -1 var BN = require('bn.js')24753 -1 var Buffer = require('safe-buffer').Buffer24754 -124755 -1 function withPublic (paddedMsg, key) {24756 -1 return Buffer.from(paddedMsg24757 -1 .toRed(BN.mont(key.modulus))24758 -1 .redPow(new BN(key.publicExponent))24759 -1 .fromRed()24760 -1 .toArray())24761 -1 }24762 -124763 -1 module.exports = withPublic24764 -124765 -1 },{"bn.js":152,"safe-buffer":160}],156:[function(require,module,exports){24766 -1 module.exports = function xor (a, b) {24767 -1 var len = a.length24768 -1 var i = -124769 -1 while (++i < len) {24770 -1 a[i] ^= b[i]24771 -1 }24772 -1 return a24773 -1 }24774 -124775 -1 },{}],157:[function(require,module,exports){24776 -1 (function (process,global){(function (){24777 -1 'use strict'24778 -124779 -1 // limit of Crypto.getRandomValues()24780 -1 // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues24781 -1 var MAX_BYTES = 6553624782 -124783 -1 // Node supports requesting up to this number of bytes24784 -1 // https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L4824785 -1 var MAX_UINT32 = 429496729524786 -124787 -1 function oldBrowser () {24788 -1 throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11')24789 -1 }24790 -124791 -1 var Buffer = require('safe-buffer').Buffer24792 -1 var crypto = global.crypto || global.msCrypto24793 -124794 -1 if (crypto && crypto.getRandomValues) {24795 -1 module.exports = randomBytes24796 -1 } else {24797 -1 module.exports = oldBrowser24798 -1 }24799 -124800 -1 function randomBytes (size, cb) {24801 -1 // phantomjs needs to throw24802 -1 if (size > MAX_UINT32) throw new RangeError('requested too many random bytes')24803 -124804 -1 var bytes = Buffer.allocUnsafe(size)24805 -124806 -1 if (size > 0) { // getRandomValues fails on IE if size == 024807 -1 if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues24808 -1 // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues24809 -1 for (var generated = 0; generated < size; generated += MAX_BYTES) {24810 -1 // buffer.slice automatically checks if the end is past the end of24811 -1 // the buffer so we don't have to here24812 -1 crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES))24813 -1 }24814 -1 } else {24815 -1 crypto.getRandomValues(bytes)24816 -1 }24817 -1 }24818 -124819 -1 if (typeof cb === 'function') {24820 -1 return process.nextTick(function () {24821 -1 cb(null, bytes)24822 -1 })24823 -1 }24824 -124825 -1 return bytes24826 -1 }24827 -124828 -1 }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})24829 -1 },{"_process":149,"safe-buffer":160}],158:[function(require,module,exports){24830 -1 (function (process,global){(function (){24831 -1 'use strict'24832 -124833 -1 function oldBrowser () {24834 -1 throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')24835 -1 }24836 -1 var safeBuffer = require('safe-buffer')24837 -1 var randombytes = require('randombytes')24838 -1 var Buffer = safeBuffer.Buffer24839 -1 var kBufferMaxLength = safeBuffer.kMaxLength24840 -1 var crypto = global.crypto || global.msCrypto24841 -1 var kMaxUint32 = Math.pow(2, 32) - 124842 -1 function assertOffset (offset, length) {24843 -1 if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare24844 -1 throw new TypeError('offset must be a number')24845 -1 }24846 -124847 -1 if (offset > kMaxUint32 || offset < 0) {24848 -1 throw new TypeError('offset must be a uint32')24849 -1 }24850 -124851 -1 if (offset > kBufferMaxLength || offset > length) {24852 -1 throw new RangeError('offset out of range')24853 -1 }24854 -1 }24855 -124856 -1 function assertSize (size, offset, length) {24857 -1 if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare24858 -1 throw new TypeError('size must be a number')24859 -1 }24860 -124861 -1 if (size > kMaxUint32 || size < 0) {24862 -1 throw new TypeError('size must be a uint32')24863 -1 }24864 -124865 -1 if (size + offset > length || size > kBufferMaxLength) {24866 -1 throw new RangeError('buffer too small')24867 -1 }24868 -1 }24869 -1 if ((crypto && crypto.getRandomValues) || !process.browser) {24870 -1 exports.randomFill = randomFill24871 -1 exports.randomFillSync = randomFillSync24872 -1 } else {24873 -1 exports.randomFill = oldBrowser24874 -1 exports.randomFillSync = oldBrowser24875 -1 }24876 -1 function randomFill (buf, offset, size, cb) {24877 -1 if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {24878 -1 throw new TypeError('"buf" argument must be a Buffer or Uint8Array')24879 -1 }24880 -124881 -1 if (typeof offset === 'function') {24882 -1 cb = offset24883 -1 offset = 024884 -1 size = buf.length24885 -1 } else if (typeof size === 'function') {24886 -1 cb = size24887 -1 size = buf.length - offset24888 -1 } else if (typeof cb !== 'function') {24889 -1 throw new TypeError('"cb" argument must be a function')24890 -1 }24891 -1 assertOffset(offset, buf.length)24892 -1 assertSize(size, offset, buf.length)24893 -1 return actualFill(buf, offset, size, cb)24894 -1 }24895 -124896 -1 function actualFill (buf, offset, size, cb) {24897 -1 if (process.browser) {24898 -1 var ourBuf = buf.buffer24899 -1 var uint = new Uint8Array(ourBuf, offset, size)24900 -1 crypto.getRandomValues(uint)24901 -1 if (cb) {24902 -1 process.nextTick(function () {24903 -1 cb(null, buf)24904 -1 })24905 -1 return24906 -1 }24907 -1 return buf24908 -1 }24909 -1 if (cb) {24910 -1 randombytes(size, function (err, bytes) {24911 -1 if (err) {24912 -1 return cb(err)24913 -1 }24914 -1 bytes.copy(buf, offset)24915 -1 cb(null, buf)24916 -1 })24917 -1 return24918 -1 }24919 -1 var bytes = randombytes(size)24920 -1 bytes.copy(buf, offset)24921 -1 return buf24922 -1 }24923 -1 function randomFillSync (buf, offset, size) {24924 -1 if (typeof offset === 'undefined') {24925 -1 offset = 024926 -1 }24927 -1 if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {24928 -1 throw new TypeError('"buf" argument must be a Buffer or Uint8Array')24929 -1 }24930 -124931 -1 assertOffset(offset, buf.length)24932 -124933 -1 if (size === undefined) size = buf.length - offset24934 -124935 -1 assertSize(size, offset, buf.length)24936 -124937 -1 return actualFill(buf, offset, size)24938 -1 }24939 -124940 -1 }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})24941 -1 },{"_process":149,"randombytes":157,"safe-buffer":160}],159:[function(require,module,exports){24942 -1 'use strict'24943 -1 var Buffer = require('buffer').Buffer24944 -1 var inherits = require('inherits')24945 -1 var HashBase = require('hash-base')24946 -124947 -1 var ARRAY16 = new Array(16)24948 -124949 -1 var zl = [24950 -1 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,24951 -1 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,24952 -1 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,24953 -1 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,24954 -1 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 1324955 -1 ]24956 -124957 -1 var zr = [24958 -1 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,24959 -1 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,24960 -1 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,24961 -1 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,24962 -1 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 1124963 -1 ]24964 -124965 -1 var sl = [24966 -1 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,24967 -1 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,24968 -1 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,24969 -1 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,24970 -1 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 624971 -1 ]24972 -124973 -1 var sr = [24974 -1 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,24975 -1 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,24976 -1 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,24977 -1 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,24978 -1 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 1124979 -1 ]24980 -124981 -1 var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e]24982 -1 var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000]24983 -124984 -1 function RIPEMD160 () {24985 -1 HashBase.call(this, 64)24986 -124987 -1 // state24988 -1 this._a = 0x6745230124989 -1 this._b = 0xefcdab8924990 -1 this._c = 0x98badcfe24991 -1 this._d = 0x1032547624992 -1 this._e = 0xc3d2e1f024993 -1 }24994 -124995 -1 inherits(RIPEMD160, HashBase)24996 -124997 -1 RIPEMD160.prototype._update = function () {24998 -1 var words = ARRAY1624999 -1 for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4)25000 -125001 -1 var al = this._a | 025002 -1 var bl = this._b | 025003 -1 var cl = this._c | 025004 -1 var dl = this._d | 025005 -1 var el = this._e | 025006 -125007 -1 var ar = this._a | 025008 -1 var br = this._b | 025009 -1 var cr = this._c | 025010 -1 var dr = this._d | 025011 -1 var er = this._e | 025012 -125013 -1 // computation25014 -1 for (var i = 0; i < 80; i += 1) {25015 -1 var tl25016 -1 var tr25017 -1 if (i < 16) {25018 -1 tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i])25019 -1 tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i])25020 -1 } else if (i < 32) {25021 -1 tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i])25022 -1 tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i])25023 -1 } else if (i < 48) {25024 -1 tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i])25025 -1 tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i])25026 -1 } else if (i < 64) {25027 -1 tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i])25028 -1 tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i])25029 -1 } else { // if (i<80) {25030 -1 tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i])25031 -1 tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i])25032 -1 }25033 -125034 -1 al = el25035 -1 el = dl25036 -1 dl = rotl(cl, 10)25037 -1 cl = bl25038 -1 bl = tl25039 -125040 -1 ar = er25041 -1 er = dr25042 -1 dr = rotl(cr, 10)25043 -1 cr = br25044 -1 br = tr25045 -1 }25046 -125047 -1 // update state25048 -1 var t = (this._b + cl + dr) | 025049 -1 this._b = (this._c + dl + er) | 025050 -1 this._c = (this._d + el + ar) | 025051 -1 this._d = (this._e + al + br) | 025052 -1 this._e = (this._a + bl + cr) | 025053 -1 this._a = t25054 -1 }25055 -125056 -1 RIPEMD160.prototype._digest = function () {25057 -1 // create padding and handle blocks25058 -1 this._block[this._blockOffset++] = 0x8025059 -1 if (this._blockOffset > 56) {25060 -1 this._block.fill(0, this._blockOffset, 64)25061 -1 this._update()25062 -1 this._blockOffset = 025063 -1 }25064 -125065 -1 this._block.fill(0, this._blockOffset, 56)25066 -1 this._block.writeUInt32LE(this._length[0], 56)25067 -1 this._block.writeUInt32LE(this._length[1], 60)25068 -1 this._update()25069 -125070 -1 // produce result25071 -1 var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20)25072 -1 buffer.writeInt32LE(this._a, 0)25073 -1 buffer.writeInt32LE(this._b, 4)25074 -1 buffer.writeInt32LE(this._c, 8)25075 -1 buffer.writeInt32LE(this._d, 12)25076 -1 buffer.writeInt32LE(this._e, 16)25077 -1 return buffer25078 -1 }25079 -125080 -1 function rotl (x, n) {25081 -1 return (x << n) | (x >>> (32 - n))25082 -1 }25083 -125084 -1 function fn1 (a, b, c, d, e, m, k, s) {25085 -1 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 025086 -1 }25087 -125088 -1 function fn2 (a, b, c, d, e, m, k, s) {25089 -1 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 025090 -1 }25091 -125092 -1 function fn3 (a, b, c, d, e, m, k, s) {25093 -1 return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 025094 -1 }25095 -125096 -1 function fn4 (a, b, c, d, e, m, k, s) {25097 -1 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 025098 -1 }25099 -125100 -1 function fn5 (a, b, c, d, e, m, k, s) {25101 -1 return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 025102 -1 }25103 -125104 -1 module.exports = RIPEMD16025105 -125106 -1 },{"buffer":63,"hash-base":102,"inherits":132}],160:[function(require,module,exports){25107 -1 /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */25108 -1 /* eslint-disable node/no-deprecated-api */25109 -1 var buffer = require('buffer')25110 -1 var Buffer = buffer.Buffer25111 -125112 -1 // alternative to using Object.keys for old browsers25113 -1 function copyProps (src, dst) {25114 -1 for (var key in src) {25115 -1 dst[key] = src[key]25116 -1 }25117 -1 }25118 -1 if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {25119 -1 module.exports = buffer25120 -1 } else {25121 -1 // Copy properties from require('buffer')25122 -1 copyProps(buffer, exports)25123 -1 exports.Buffer = SafeBuffer25124 -1 }25125 -125126 -1 function SafeBuffer (arg, encodingOrOffset, length) {25127 -1 return Buffer(arg, encodingOrOffset, length)25128 -1 }25129 -125130 -1 SafeBuffer.prototype = Object.create(Buffer.prototype)25131 -125132 -1 // Copy static methods from Buffer25133 -1 copyProps(Buffer, SafeBuffer)25134 -125135 -1 SafeBuffer.from = function (arg, encodingOrOffset, length) {25136 -1 if (typeof arg === 'number') {25137 -1 throw new TypeError('Argument must not be a number')25138 -1 }25139 -1 return Buffer(arg, encodingOrOffset, length)25140 -1 }25141 -125142 -1 SafeBuffer.alloc = function (size, fill, encoding) {25143 -1 if (typeof size !== 'number') {25144 -1 throw new TypeError('Argument must be a number')25145 -1 }25146 -1 var buf = Buffer(size)25147 -1 if (fill !== undefined) {25148 -1 if (typeof encoding === 'string') {25149 -1 buf.fill(fill, encoding)25150 -1 } else {25151 -1 buf.fill(fill)25152 -1 }25153 -1 } else {25154 -1 buf.fill(0)25155 -1 }25156 -1 return buf25157 -1 }25158 -125159 -1 SafeBuffer.allocUnsafe = function (size) {25160 -1 if (typeof size !== 'number') {25161 -1 throw new TypeError('Argument must be a number')25162 -1 }25163 -1 return Buffer(size)25164 -1 }25165 -125166 -1 SafeBuffer.allocUnsafeSlow = function (size) {25167 -1 if (typeof size !== 'number') {25168 -1 throw new TypeError('Argument must be a number')25169 -1 }25170 -1 return buffer.SlowBuffer(size)25171 -1 }25172 -125173 -1 },{"buffer":63}],161:[function(require,module,exports){25174 -1 (function (process){(function (){25175 -1 /* eslint-disable node/no-deprecated-api */25176 -125177 -1 'use strict'25178 -125179 -1 var buffer = require('buffer')25180 -1 var Buffer = buffer.Buffer25181 -125182 -1 var safer = {}25183 -125184 -1 var key25185 -125186 -1 for (key in buffer) {25187 -1 if (!buffer.hasOwnProperty(key)) continue25188 -1 if (key === 'SlowBuffer' || key === 'Buffer') continue25189 -1 safer[key] = buffer[key]25190 -1 }25191 -125192 -1 var Safer = safer.Buffer = {}25193 -1 for (key in Buffer) {25194 -1 if (!Buffer.hasOwnProperty(key)) continue25195 -1 if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue25196 -1 Safer[key] = Buffer[key]25197 -1 }25198 -125199 -1 safer.Buffer.prototype = Buffer.prototype25200 -125201 -1 if (!Safer.from || Safer.from === Uint8Array.from) {25202 -1 Safer.from = function (value, encodingOrOffset, length) {25203 -1 if (typeof value === 'number') {25204 -1 throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value)25205 -1 }25206 -1 if (value && typeof value.length === 'undefined') {25207 -1 throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value)25208 -1 }25209 -1 return Buffer(value, encodingOrOffset, length)25210 -1 }25211 -1 }25212 -125213 -1 if (!Safer.alloc) {25214 -1 Safer.alloc = function (size, fill, encoding) {25215 -1 if (typeof size !== 'number') {25216 -1 throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size)25217 -1 }25218 -1 if (size < 0 || size >= 2 * (1 << 30)) {25219 -1 throw new RangeError('The value "' + size + '" is invalid for option "size"')25220 -1 }25221 -1 var buf = Buffer(size)25222 -1 if (!fill || fill.length === 0) {25223 -1 buf.fill(0)25224 -1 } else if (typeof encoding === 'string') {25225 -1 buf.fill(fill, encoding)25226 -1 } else {25227 -1 buf.fill(fill)25228 -1 }25229 -1 return buf25230 -1 }25231 -1 }25232 -125233 -1 if (!safer.kStringMaxLength) {25234 -1 try {25235 -1 safer.kStringMaxLength = process.binding('buffer').kStringMaxLength25236 -1 } catch (e) {25237 -1 // we can't determine kStringMaxLength in environments where process.binding25238 -1 // is unsupported, so let's not set it25239 -1 }25240 -1 }25241 -125242 -1 if (!safer.constants) {25243 -1 safer.constants = {25244 -1 MAX_LENGTH: safer.kMaxLength25245 -1 }25246 -1 if (safer.kStringMaxLength) {25247 -1 safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength25248 -1 }25249 -1 }25250 -125251 -1 module.exports = safer25252 -125253 -1 }).call(this)}).call(this,require('_process'))25254 -1 },{"_process":149,"buffer":63}],162:[function(require,module,exports){25255 -1 var Buffer = require('safe-buffer').Buffer25256 -125257 -1 // prototype class for hash functions25258 -1 function Hash (blockSize, finalSize) {25259 -1 this._block = Buffer.alloc(blockSize)25260 -1 this._finalSize = finalSize25261 -1 this._blockSize = blockSize25262 -1 this._len = 025263 -1 }25264 -125265 -1 Hash.prototype.update = function (data, enc) {25266 -1 if (typeof data === 'string') {25267 -1 enc = enc || 'utf8'25268 -1 data = Buffer.from(data, enc)25269 -1 }25270 -125271 -1 var block = this._block25272 -1 var blockSize = this._blockSize25273 -1 var length = data.length25274 -1 var accum = this._len25275 -125276 -1 for (var offset = 0; offset < length;) {25277 -1 var assigned = accum % blockSize25278 -1 var remainder = Math.min(length - offset, blockSize - assigned)25279 -125280 -1 for (var i = 0; i < remainder; i++) {25281 -1 block[assigned + i] = data[offset + i]25282 -1 }25283 -125284 -1 accum += remainder25285 -1 offset += remainder25286 -125287 -1 if ((accum % blockSize) === 0) {25288 -1 this._update(block)25289 -1 }25290 -1 }25291 -125292 -1 this._len += length25293 -1 return this25294 -1 }25295 -125296 -1 Hash.prototype.digest = function (enc) {25297 -1 var rem = this._len % this._blockSize25298 -125299 -1 this._block[rem] = 0x8025300 -125301 -1 // zero (rem + 1) trailing bits, where (rem + 1) is the smallest25302 -1 // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize25303 -1 this._block.fill(0, rem + 1)25304 -125305 -1 if (rem >= this._finalSize) {25306 -1 this._update(this._block)25307 -1 this._block.fill(0)25308 -1 }25309 -125310 -1 var bits = this._len * 825311 -125312 -1 // uint3225313 -1 if (bits <= 0xffffffff) {25314 -1 this._block.writeUInt32BE(bits, this._blockSize - 4)25315 -125316 -1 // uint6425317 -1 } else {25318 -1 var lowBits = (bits & 0xffffffff) >>> 025319 -1 var highBits = (bits - lowBits) / 0x10000000025320 -125321 -1 this._block.writeUInt32BE(highBits, this._blockSize - 8)25322 -1 this._block.writeUInt32BE(lowBits, this._blockSize - 4)25323 -1 }25324 -125325 -1 this._update(this._block)25326 -1 var hash = this._hash()25327 -125328 -1 return enc ? hash.toString(enc) : hash25329 -1 }25330 -125331 -1 Hash.prototype._update = function () {25332 -1 throw new Error('_update must be implemented by subclass')25333 -1 }25334 -125335 -1 module.exports = Hash25336 -125337 -1 },{"safe-buffer":160}],163:[function(require,module,exports){25338 -1 var exports = module.exports = function SHA (algorithm) {25339 -1 algorithm = algorithm.toLowerCase()25340 -125341 -1 var Algorithm = exports[algorithm]25342 -1 if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')25343 -125344 -1 return new Algorithm()25345 -1 }25346 -125347 -1 exports.sha = require('./sha')25348 -1 exports.sha1 = require('./sha1')25349 -1 exports.sha224 = require('./sha224')25350 -1 exports.sha256 = require('./sha256')25351 -1 exports.sha384 = require('./sha384')25352 -1 exports.sha512 = require('./sha512')25353 -125354 -1 },{"./sha":164,"./sha1":165,"./sha224":166,"./sha256":167,"./sha384":168,"./sha512":169}],164:[function(require,module,exports){25355 -1 /*25356 -1 * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined25357 -1 * in FIPS PUB 180-125358 -1 * This source code is derived from sha1.js of the same repository.25359 -1 * The difference between SHA-0 and SHA-1 is just a bitwise rotate left25360 -1 * operation was added.25361 -1 */25362 -125363 -1 var inherits = require('inherits')25364 -1 var Hash = require('./hash')25365 -1 var Buffer = require('safe-buffer').Buffer25366 -125367 -1 var K = [25368 -1 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 025369 -1 ]25370 -125371 -1 var W = new Array(80)25372 -125373 -1 function Sha () {25374 -1 this.init()25375 -1 this._w = W25376 -125377 -1 Hash.call(this, 64, 56)25378 -1 }25379 -125380 -1 inherits(Sha, Hash)25381 -125382 -1 Sha.prototype.init = function () {25383 -1 this._a = 0x6745230125384 -1 this._b = 0xefcdab8925385 -1 this._c = 0x98badcfe25386 -1 this._d = 0x1032547625387 -1 this._e = 0xc3d2e1f025388 -125389 -1 return this25390 -1 }25391 -125392 -1 function rotl5 (num) {25393 -1 return (num << 5) | (num >>> 27)25394 -1 }25395 -125396 -1 function rotl30 (num) {25397 -1 return (num << 30) | (num >>> 2)25398 -1 }25399 -125400 -1 function ft (s, b, c, d) {25401 -1 if (s === 0) return (b & c) | ((~b) & d)25402 -1 if (s === 2) return (b & c) | (b & d) | (c & d)25403 -1 return b ^ c ^ d25404 -1 }25405 -125406 -1 Sha.prototype._update = function (M) {25407 -1 var W = this._w25408 -125409 -1 var a = this._a | 025410 -1 var b = this._b | 025411 -1 var c = this._c | 025412 -1 var d = this._d | 025413 -1 var e = this._e | 025414 -125415 -1 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)25416 -1 for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]25417 -125418 -1 for (var j = 0; j < 80; ++j) {25419 -1 var s = ~~(j / 20)25420 -1 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 025421 -125422 -1 e = d25423 -1 d = c25424 -1 c = rotl30(b)25425 -1 b = a25426 -1 a = t25427 -1 }25428 -125429 -1 this._a = (a + this._a) | 025430 -1 this._b = (b + this._b) | 025431 -1 this._c = (c + this._c) | 025432 -1 this._d = (d + this._d) | 025433 -1 this._e = (e + this._e) | 025434 -1 }25435 -125436 -1 Sha.prototype._hash = function () {25437 -1 var H = Buffer.allocUnsafe(20)25438 -125439 -1 H.writeInt32BE(this._a | 0, 0)25440 -1 H.writeInt32BE(this._b | 0, 4)25441 -1 H.writeInt32BE(this._c | 0, 8)25442 -1 H.writeInt32BE(this._d | 0, 12)25443 -1 H.writeInt32BE(this._e | 0, 16)25444 -125445 -1 return H25446 -1 }25447 -125448 -1 module.exports = Sha25449 -125450 -1 },{"./hash":162,"inherits":132,"safe-buffer":160}],165:[function(require,module,exports){25451 -1 /*25452 -1 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined25453 -1 * in FIPS PUB 180-125454 -1 * Version 2.1a Copyright Paul Johnston 2000 - 2002.25455 -1 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet25456 -1 * Distributed under the BSD License25457 -1 * See http://pajhome.org.uk/crypt/md5 for details.25458 -1 */25459 -125460 -1 var inherits = require('inherits')25461 -1 var Hash = require('./hash')25462 -1 var Buffer = require('safe-buffer').Buffer25463 -125464 -1 var K = [25465 -1 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 025466 -1 ]25467 -125468 -1 var W = new Array(80)25469 -125470 -1 function Sha1 () {25471 -1 this.init()25472 -1 this._w = W25473 -125474 -1 Hash.call(this, 64, 56)25475 -1 }25476 -125477 -1 inherits(Sha1, Hash)25478 -125479 -1 Sha1.prototype.init = function () {25480 -1 this._a = 0x6745230125481 -1 this._b = 0xefcdab8925482 -1 this._c = 0x98badcfe25483 -1 this._d = 0x1032547625484 -1 this._e = 0xc3d2e1f025485 -125486 -1 return this25487 -1 }25488 -125489 -1 function rotl1 (num) {25490 -1 return (num << 1) | (num >>> 31)25491 -1 }25492 -125493 -1 function rotl5 (num) {25494 -1 return (num << 5) | (num >>> 27)25495 -1 }25496 -125497 -1 function rotl30 (num) {25498 -1 return (num << 30) | (num >>> 2)25499 -1 }25500 -125501 -1 function ft (s, b, c, d) {25502 -1 if (s === 0) return (b & c) | ((~b) & d)25503 -1 if (s === 2) return (b & c) | (b & d) | (c & d)25504 -1 return b ^ c ^ d25505 -1 }25506 -125507 -1 Sha1.prototype._update = function (M) {25508 -1 var W = this._w25509 -125510 -1 var a = this._a | 025511 -1 var b = this._b | 025512 -1 var c = this._c | 025513 -1 var d = this._d | 025514 -1 var e = this._e | 025515 -125516 -1 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)25517 -1 for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])25518 -125519 -1 for (var j = 0; j < 80; ++j) {25520 -1 var s = ~~(j / 20)25521 -1 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 025522 -125523 -1 e = d25524 -1 d = c25525 -1 c = rotl30(b)25526 -1 b = a25527 -1 a = t25528 -1 }25529 -125530 -1 this._a = (a + this._a) | 025531 -1 this._b = (b + this._b) | 025532 -1 this._c = (c + this._c) | 025533 -1 this._d = (d + this._d) | 025534 -1 this._e = (e + this._e) | 025535 -1 }25536 -125537 -1 Sha1.prototype._hash = function () {25538 -1 var H = Buffer.allocUnsafe(20)25539 -125540 -1 H.writeInt32BE(this._a | 0, 0)25541 -1 H.writeInt32BE(this._b | 0, 4)25542 -1 H.writeInt32BE(this._c | 0, 8)25543 -1 H.writeInt32BE(this._d | 0, 12)25544 -1 H.writeInt32BE(this._e | 0, 16)25545 -125546 -1 return H25547 -1 }25548 -125549 -1 module.exports = Sha125550 -125551 -1 },{"./hash":162,"inherits":132,"safe-buffer":160}],166:[function(require,module,exports){25552 -1 /**25553 -1 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined25554 -1 * in FIPS 180-225555 -1 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.25556 -1 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet25557 -1 *25558 -1 */25559 -125560 -1 var inherits = require('inherits')25561 -1 var Sha256 = require('./sha256')25562 -1 var Hash = require('./hash')25563 -1 var Buffer = require('safe-buffer').Buffer25564 -125565 -1 var W = new Array(64)25566 -125567 -1 function Sha224 () {25568 -1 this.init()25569 -125570 -1 this._w = W // new Array(64)25571 -125572 -1 Hash.call(this, 64, 56)25573 -1 }25574 -125575 -1 inherits(Sha224, Sha256)25576 -125577 -1 Sha224.prototype.init = function () {25578 -1 this._a = 0xc1059ed825579 -1 this._b = 0x367cd50725580 -1 this._c = 0x3070dd1725581 -1 this._d = 0xf70e593925582 -1 this._e = 0xffc00b3125583 -1 this._f = 0x6858151125584 -1 this._g = 0x64f98fa725585 -1 this._h = 0xbefa4fa425586 -125587 -1 return this25588 -1 }25589 -125590 -1 Sha224.prototype._hash = function () {25591 -1 var H = Buffer.allocUnsafe(28)25592 -125593 -1 H.writeInt32BE(this._a, 0)25594 -1 H.writeInt32BE(this._b, 4)25595 -1 H.writeInt32BE(this._c, 8)25596 -1 H.writeInt32BE(this._d, 12)25597 -1 H.writeInt32BE(this._e, 16)25598 -1 H.writeInt32BE(this._f, 20)25599 -1 H.writeInt32BE(this._g, 24)25600 -125601 -1 return H25602 -1 }25603 -125604 -1 module.exports = Sha22425605 -125606 -1 },{"./hash":162,"./sha256":167,"inherits":132,"safe-buffer":160}],167:[function(require,module,exports){25607 -1 /**25608 -1 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined25609 -1 * in FIPS 180-225610 -1 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.25611 -1 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet25612 -1 *25613 -1 */25614 -125615 -1 var inherits = require('inherits')25616 -1 var Hash = require('./hash')25617 -1 var Buffer = require('safe-buffer').Buffer25618 -125619 -1 var K = [25620 -1 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,25621 -1 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,25622 -1 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,25623 -1 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,25624 -1 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,25625 -1 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,25626 -1 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,25627 -1 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,25628 -1 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,25629 -1 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,25630 -1 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,25631 -1 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,25632 -1 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,25633 -1 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,25634 -1 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,25635 -1 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F225636 -1 ]25637 -125638 -1 var W = new Array(64)25639 -125640 -1 function Sha256 () {25641 -1 this.init()25642 -125643 -1 this._w = W // new Array(64)25644 -125645 -1 Hash.call(this, 64, 56)25646 -1 }25647 -125648 -1 inherits(Sha256, Hash)25649 -125650 -1 Sha256.prototype.init = function () {25651 -1 this._a = 0x6a09e66725652 -1 this._b = 0xbb67ae8525653 -1 this._c = 0x3c6ef37225654 -1 this._d = 0xa54ff53a25655 -1 this._e = 0x510e527f25656 -1 this._f = 0x9b05688c25657 -1 this._g = 0x1f83d9ab25658 -1 this._h = 0x5be0cd1925659 -125660 -1 return this25661 -1 }25662 -125663 -1 function ch (x, y, z) {25664 -1 return z ^ (x & (y ^ z))25665 -1 }25666 -125667 -1 function maj (x, y, z) {25668 -1 return (x & y) | (z & (x | y))25669 -1 }25670 -125671 -1 function sigma0 (x) {25672 -1 return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)25673 -1 }25674 -125675 -1 function sigma1 (x) {25676 -1 return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)25677 -1 }25678 -125679 -1 function gamma0 (x) {25680 -1 return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)25681 -1 }25682 -125683 -1 function gamma1 (x) {25684 -1 return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)25685 -1 }25686 -125687 -1 Sha256.prototype._update = function (M) {25688 -1 var W = this._w25689 -125690 -1 var a = this._a | 025691 -1 var b = this._b | 025692 -1 var c = this._c | 025693 -1 var d = this._d | 025694 -1 var e = this._e | 025695 -1 var f = this._f | 025696 -1 var g = this._g | 025697 -1 var h = this._h | 025698 -125699 -1 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)25700 -1 for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 025701 -125702 -1 for (var j = 0; j < 64; ++j) {25703 -1 var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 025704 -1 var T2 = (sigma0(a) + maj(a, b, c)) | 025705 -125706 -1 h = g25707 -1 g = f25708 -1 f = e25709 -1 e = (d + T1) | 025710 -1 d = c25711 -1 c = b25712 -1 b = a25713 -1 a = (T1 + T2) | 025714 -1 }25715 -125716 -1 this._a = (a + this._a) | 025717 -1 this._b = (b + this._b) | 025718 -1 this._c = (c + this._c) | 025719 -1 this._d = (d + this._d) | 025720 -1 this._e = (e + this._e) | 025721 -1 this._f = (f + this._f) | 025722 -1 this._g = (g + this._g) | 025723 -1 this._h = (h + this._h) | 025724 -1 }25725 -125726 -1 Sha256.prototype._hash = function () {25727 -1 var H = Buffer.allocUnsafe(32)25728 -125729 -1 H.writeInt32BE(this._a, 0)25730 -1 H.writeInt32BE(this._b, 4)25731 -1 H.writeInt32BE(this._c, 8)25732 -1 H.writeInt32BE(this._d, 12)25733 -1 H.writeInt32BE(this._e, 16)25734 -1 H.writeInt32BE(this._f, 20)25735 -1 H.writeInt32BE(this._g, 24)25736 -1 H.writeInt32BE(this._h, 28)25737 -125738 -1 return H25739 -1 }25740 -125741 -1 module.exports = Sha25625742 -125743 -1 },{"./hash":162,"inherits":132,"safe-buffer":160}],168:[function(require,module,exports){25744 -1 var inherits = require('inherits')25745 -1 var SHA512 = require('./sha512')25746 -1 var Hash = require('./hash')25747 -1 var Buffer = require('safe-buffer').Buffer25748 -125749 -1 var W = new Array(160)25750 -125751 -1 function Sha384 () {25752 -1 this.init()25753 -1 this._w = W25754 -125755 -1 Hash.call(this, 128, 112)25756 -1 }25757 -125758 -1 inherits(Sha384, SHA512)25759 -125760 -1 Sha384.prototype.init = function () {25761 -1 this._ah = 0xcbbb9d5d25762 -1 this._bh = 0x629a292a25763 -1 this._ch = 0x9159015a25764 -1 this._dh = 0x152fecd825765 -1 this._eh = 0x6733266725766 -1 this._fh = 0x8eb44a8725767 -1 this._gh = 0xdb0c2e0d25768 -1 this._hh = 0x47b5481d25769 -125770 -1 this._al = 0xc1059ed825771 -1 this._bl = 0x367cd50725772 -1 this._cl = 0x3070dd1725773 -1 this._dl = 0xf70e593925774 -1 this._el = 0xffc00b3125775 -1 this._fl = 0x6858151125776 -1 this._gl = 0x64f98fa725777 -1 this._hl = 0xbefa4fa425778 -125779 -1 return this25780 -1 }25781 -125782 -1 Sha384.prototype._hash = function () {25783 -1 var H = Buffer.allocUnsafe(48)25784 -125785 -1 function writeInt64BE (h, l, offset) {25786 -1 H.writeInt32BE(h, offset)25787 -1 H.writeInt32BE(l, offset + 4)25788 -1 }25789 -125790 -1 writeInt64BE(this._ah, this._al, 0)25791 -1 writeInt64BE(this._bh, this._bl, 8)25792 -1 writeInt64BE(this._ch, this._cl, 16)25793 -1 writeInt64BE(this._dh, this._dl, 24)25794 -1 writeInt64BE(this._eh, this._el, 32)25795 -1 writeInt64BE(this._fh, this._fl, 40)25796 -125797 -1 return H25798 -1 }25799 -125800 -1 module.exports = Sha38425801 -125802 -1 },{"./hash":162,"./sha512":169,"inherits":132,"safe-buffer":160}],169:[function(require,module,exports){25803 -1 var inherits = require('inherits')25804 -1 var Hash = require('./hash')25805 -1 var Buffer = require('safe-buffer').Buffer25806 -125807 -1 var K = [25808 -1 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,25809 -1 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,25810 -1 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,25811 -1 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,25812 -1 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,25813 -1 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,25814 -1 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,25815 -1 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,25816 -1 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,25817 -1 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,25818 -1 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,25819 -1 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,25820 -1 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,25821 -1 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,25822 -1 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,25823 -1 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,25824 -1 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,25825 -1 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,25826 -1 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,25827 -1 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,25828 -1 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,25829 -1 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,25830 -1 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,25831 -1 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,25832 -1 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,25833 -1 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,25834 -1 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,25835 -1 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,25836 -1 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,25837 -1 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,25838 -1 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,25839 -1 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,25840 -1 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,25841 -1 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,25842 -1 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,25843 -1 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,25844 -1 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,25845 -1 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,25846 -1 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,25847 -1 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a47581725848 -1 ]25849 -125850 -1 var W = new Array(160)25851 -125852 -1 function Sha512 () {25853 -1 this.init()25854 -1 this._w = W25855 -125856 -1 Hash.call(this, 128, 112)25857 -1 }25858 -125859 -1 inherits(Sha512, Hash)25860 -125861 -1 Sha512.prototype.init = function () {25862 -1 this._ah = 0x6a09e66725863 -1 this._bh = 0xbb67ae8525864 -1 this._ch = 0x3c6ef37225865 -1 this._dh = 0xa54ff53a25866 -1 this._eh = 0x510e527f25867 -1 this._fh = 0x9b05688c25868 -1 this._gh = 0x1f83d9ab25869 -1 this._hh = 0x5be0cd1925870 -125871 -1 this._al = 0xf3bcc90825872 -1 this._bl = 0x84caa73b25873 -1 this._cl = 0xfe94f82b25874 -1 this._dl = 0x5f1d36f125875 -1 this._el = 0xade682d125876 -1 this._fl = 0x2b3e6c1f25877 -1 this._gl = 0xfb41bd6b25878 -1 this._hl = 0x137e217925879 -125880 -1 return this25881 -1 }25882 -125883 -1 function Ch (x, y, z) {25884 -1 return z ^ (x & (y ^ z))25885 -1 }25886 -125887 -1 function maj (x, y, z) {25888 -1 return (x & y) | (z & (x | y))25889 -1 }25890 -125891 -1 function sigma0 (x, xl) {25892 -1 return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)25893 -1 }25894 -125895 -1 function sigma1 (x, xl) {25896 -1 return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)25897 -1 }25898 -125899 -1 function Gamma0 (x, xl) {25900 -1 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)25901 -1 }25902 -125903 -1 function Gamma0l (x, xl) {25904 -1 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)25905 -1 }25906 -125907 -1 function Gamma1 (x, xl) {25908 -1 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)25909 -1 }25910 -125911 -1 function Gamma1l (x, xl) {25912 -1 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)25913 -1 }25914 -125915 -1 function getCarry (a, b) {25916 -1 return (a >>> 0) < (b >>> 0) ? 1 : 025917 -1 }25918 -125919 -1 Sha512.prototype._update = function (M) {25920 -1 var W = this._w25921 -125922 -1 var ah = this._ah | 025923 -1 var bh = this._bh | 025924 -1 var ch = this._ch | 025925 -1 var dh = this._dh | 025926 -1 var eh = this._eh | 025927 -1 var fh = this._fh | 025928 -1 var gh = this._gh | 025929 -1 var hh = this._hh | 025930 -125931 -1 var al = this._al | 025932 -1 var bl = this._bl | 025933 -1 var cl = this._cl | 025934 -1 var dl = this._dl | 025935 -1 var el = this._el | 025936 -1 var fl = this._fl | 025937 -1 var gl = this._gl | 025938 -1 var hl = this._hl | 025939 -125940 -1 for (var i = 0; i < 32; i += 2) {25941 -1 W[i] = M.readInt32BE(i * 4)25942 -1 W[i + 1] = M.readInt32BE(i * 4 + 4)25943 -1 }25944 -1 for (; i < 160; i += 2) {25945 -1 var xh = W[i - 15 * 2]25946 -1 var xl = W[i - 15 * 2 + 1]25947 -1 var gamma0 = Gamma0(xh, xl)25948 -1 var gamma0l = Gamma0l(xl, xh)25949 -125950 -1 xh = W[i - 2 * 2]25951 -1 xl = W[i - 2 * 2 + 1]25952 -1 var gamma1 = Gamma1(xh, xl)25953 -1 var gamma1l = Gamma1l(xl, xh)25954 -125955 -1 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]25956 -1 var Wi7h = W[i - 7 * 2]25957 -1 var Wi7l = W[i - 7 * 2 + 1]25958 -125959 -1 var Wi16h = W[i - 16 * 2]25960 -1 var Wi16l = W[i - 16 * 2 + 1]25961 -125962 -1 var Wil = (gamma0l + Wi7l) | 025963 -1 var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 025964 -1 Wil = (Wil + gamma1l) | 025965 -1 Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 025966 -1 Wil = (Wil + Wi16l) | 025967 -1 Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 025968 -125969 -1 W[i] = Wih25970 -1 W[i + 1] = Wil25971 -1 }25972 -125973 -1 for (var j = 0; j < 160; j += 2) {25974 -1 Wih = W[j]25975 -1 Wil = W[j + 1]25976 -125977 -1 var majh = maj(ah, bh, ch)25978 -1 var majl = maj(al, bl, cl)25979 -125980 -1 var sigma0h = sigma0(ah, al)25981 -1 var sigma0l = sigma0(al, ah)25982 -1 var sigma1h = sigma1(eh, el)25983 -1 var sigma1l = sigma1(el, eh)25984 -125985 -1 // t1 = h + sigma1 + ch + K[j] + W[j]25986 -1 var Kih = K[j]25987 -1 var Kil = K[j + 1]25988 -125989 -1 var chh = Ch(eh, fh, gh)25990 -1 var chl = Ch(el, fl, gl)25991 -125992 -1 var t1l = (hl + sigma1l) | 025993 -1 var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 025994 -1 t1l = (t1l + chl) | 025995 -1 t1h = (t1h + chh + getCarry(t1l, chl)) | 025996 -1 t1l = (t1l + Kil) | 025997 -1 t1h = (t1h + Kih + getCarry(t1l, Kil)) | 025998 -1 t1l = (t1l + Wil) | 025999 -1 t1h = (t1h + Wih + getCarry(t1l, Wil)) | 026000 -126001 -1 // t2 = sigma0 + maj26002 -1 var t2l = (sigma0l + majl) | 026003 -1 var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 026004 -126005 -1 hh = gh26006 -1 hl = gl26007 -1 gh = fh26008 -1 gl = fl26009 -1 fh = eh26010 -1 fl = el26011 -1 el = (dl + t1l) | 026012 -1 eh = (dh + t1h + getCarry(el, dl)) | 026013 -1 dh = ch26014 -1 dl = cl26015 -1 ch = bh26016 -1 cl = bl26017 -1 bh = ah26018 -1 bl = al26019 -1 al = (t1l + t2l) | 026020 -1 ah = (t1h + t2h + getCarry(al, t1l)) | 026021 -1 }26022 -126023 -1 this._al = (this._al + al) | 026024 -1 this._bl = (this._bl + bl) | 026025 -1 this._cl = (this._cl + cl) | 026026 -1 this._dl = (this._dl + dl) | 026027 -1 this._el = (this._el + el) | 026028 -1 this._fl = (this._fl + fl) | 026029 -1 this._gl = (this._gl + gl) | 026030 -1 this._hl = (this._hl + hl) | 026031 -126032 -1 this._ah = (this._ah + ah + getCarry(this._al, al)) | 026033 -1 this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 026034 -1 this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 026035 -1 this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 026036 -1 this._eh = (this._eh + eh + getCarry(this._el, el)) | 026037 -1 this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 026038 -1 this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 026039 -1 this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 026040 -1 }26041 -126042 -1 Sha512.prototype._hash = function () {26043 -1 var H = Buffer.allocUnsafe(64)26044 -126045 -1 function writeInt64BE (h, l, offset) {26046 -1 H.writeInt32BE(h, offset)26047 -1 H.writeInt32BE(l, offset + 4)26048 -1 }26049 -126050 -1 writeInt64BE(this._ah, this._al, 0)26051 -1 writeInt64BE(this._bh, this._bl, 8)26052 -1 writeInt64BE(this._ch, this._cl, 16)26053 -1 writeInt64BE(this._dh, this._dl, 24)26054 -1 writeInt64BE(this._eh, this._el, 32)26055 -1 writeInt64BE(this._fh, this._fl, 40)26056 -1 writeInt64BE(this._gh, this._gl, 48)26057 -1 writeInt64BE(this._hh, this._hl, 56)26058 -126059 -1 return H26060 -1 }26061 -126062 -1 module.exports = Sha51226063 -126064 -1 },{"./hash":162,"inherits":132,"safe-buffer":160}],170:[function(require,module,exports){26065 -1 // Copyright Joyent, Inc. and other Node contributors.26066 -1 //26067 -1 // Permission is hereby granted, free of charge, to any person obtaining a26068 -1 // copy of this software and associated documentation files (the26069 -1 // "Software"), to deal in the Software without restriction, including26070 -1 // without limitation the rights to use, copy, modify, merge, publish,26071 -1 // distribute, sublicense, and/or sell copies of the Software, and to permit26072 -1 // persons to whom the Software is furnished to do so, subject to the26073 -1 // following conditions:26074 -1 //26075 -1 // The above copyright notice and this permission notice shall be included26076 -1 // in all copies or substantial portions of the Software.26077 -1 //26078 -1 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS26079 -1 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF26080 -1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN26081 -1 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,26082 -1 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR26083 -1 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE26084 -1 // USE OR OTHER DEALINGS IN THE SOFTWARE.26085 -126086 -1 module.exports = Stream;26087 -126088 -1 var EE = require('events').EventEmitter;26089 -1 var inherits = require('inherits');26090 -126091 -1 inherits(Stream, EE);26092 -1 Stream.Readable = require('readable-stream/lib/_stream_readable.js');26093 -1 Stream.Writable = require('readable-stream/lib/_stream_writable.js');26094 -1 Stream.Duplex = require('readable-stream/lib/_stream_duplex.js');26095 -1 Stream.Transform = require('readable-stream/lib/_stream_transform.js');26096 -1 Stream.PassThrough = require('readable-stream/lib/_stream_passthrough.js');26097 -1 Stream.finished = require('readable-stream/lib/internal/streams/end-of-stream.js')26098 -1 Stream.pipeline = require('readable-stream/lib/internal/streams/pipeline.js')26099 -126100 -1 // Backwards-compat with node 0.4.x26101 -1 Stream.Stream = Stream;26102 -126103 -126104 -126105 -1 // old-style streams. Note that the pipe method (the only relevant26106 -1 // part of this class) is overridden in the Readable class.26107 -126108 -1 function Stream() {26109 -1 EE.call(this);26110 -1 }26111 -126112 -1 Stream.prototype.pipe = function(dest, options) {26113 -1 var source = this;26114 -126115 -1 function ondata(chunk) {26116 -1 if (dest.writable) {26117 -1 if (false === dest.write(chunk) && source.pause) {26118 -1 source.pause();26119 -1 }26120 -1 }26121 -1 }26122 -126123 -1 source.on('data', ondata);26124 -126125 -1 function ondrain() {26126 -1 if (source.readable && source.resume) {26127 -1 source.resume();26128 -1 }26129 -1 }26130 -126131 -1 dest.on('drain', ondrain);26132 -126133 -1 // If the 'end' option is not supplied, dest.end() will be called when26134 -1 // source gets the 'end' or 'close' events. Only dest.end() once.26135 -1 if (!dest._isStdio && (!options || options.end !== false)) {26136 -1 source.on('end', onend);26137 -1 source.on('close', onclose);26138 -1 }26139 -126140 -1 var didOnEnd = false;26141 -1 function onend() {26142 -1 if (didOnEnd) return;26143 -1 didOnEnd = true;26144 -126145 -1 dest.end();26146 -1 }26147 -126148 -126149 -1 function onclose() {26150 -1 if (didOnEnd) return;26151 -1 didOnEnd = true;26152 -126153 -1 if (typeof dest.destroy === 'function') dest.destroy();26154 -1 }26155 -126156 -1 // don't leave dangling pipes when there are errors.26157 -1 function onerror(er) {26158 -1 cleanup();26159 -1 if (EE.listenerCount(this, 'error') === 0) {26160 -1 throw er; // Unhandled stream error in pipe.26161 -1 }26162 -1 }26163 -126164 -1 source.on('error', onerror);26165 -1 dest.on('error', onerror);26166 -126167 -1 // remove all the event listeners that were added.26168 -1 function cleanup() {26169 -1 source.removeListener('data', ondata);26170 -1 dest.removeListener('drain', ondrain);26171 -126172 -1 source.removeListener('end', onend);26173 -1 source.removeListener('close', onclose);26174 -126175 -1 source.removeListener('error', onerror);26176 -1 dest.removeListener('error', onerror);26177 -126178 -1 source.removeListener('end', cleanup);26179 -1 source.removeListener('close', cleanup);26180 -126181 -1 dest.removeListener('close', cleanup);26182 -1 }26183 -126184 -1 source.on('end', cleanup);26185 -1 source.on('close', cleanup);26186 -126187 -1 dest.on('close', cleanup);26188 -126189 -1 dest.emit('pipe', source);26190 -126191 -1 // Allow for unix-like usage: A.pipe(B).pipe(C)26192 -1 return dest;26193 -1 };26194 -126195 -1 },{"events":100,"inherits":132,"readable-stream/lib/_stream_duplex.js":172,"readable-stream/lib/_stream_passthrough.js":173,"readable-stream/lib/_stream_readable.js":174,"readable-stream/lib/_stream_transform.js":175,"readable-stream/lib/_stream_writable.js":176,"readable-stream/lib/internal/streams/end-of-stream.js":180,"readable-stream/lib/internal/streams/pipeline.js":182}],171:[function(require,module,exports){26196 -1 arguments[4][47][0].apply(exports,arguments)26197 -1 },{"dup":47}],172:[function(require,module,exports){26198 -1 arguments[4][48][0].apply(exports,arguments)26199 -1 },{"./_stream_readable":174,"./_stream_writable":176,"_process":149,"dup":48,"inherits":132}],173:[function(require,module,exports){26200 -1 arguments[4][49][0].apply(exports,arguments)26201 -1 },{"./_stream_transform":175,"dup":49,"inherits":132}],174:[function(require,module,exports){26202 -1 arguments[4][50][0].apply(exports,arguments)26203 -1 },{"../errors":171,"./_stream_duplex":172,"./internal/streams/async_iterator":177,"./internal/streams/buffer_list":178,"./internal/streams/destroy":179,"./internal/streams/from":181,"./internal/streams/state":183,"./internal/streams/stream":184,"_process":149,"buffer":63,"dup":50,"events":100,"inherits":132,"string_decoder/":185,"util":19}],175:[function(require,module,exports){26204 -1 arguments[4][51][0].apply(exports,arguments)26205 -1 },{"../errors":171,"./_stream_duplex":172,"dup":51,"inherits":132}],176:[function(require,module,exports){26206 -1 arguments[4][52][0].apply(exports,arguments)26207 -1 },{"../errors":171,"./_stream_duplex":172,"./internal/streams/destroy":179,"./internal/streams/state":183,"./internal/streams/stream":184,"_process":149,"buffer":63,"dup":52,"inherits":132,"util-deprecate":187}],177:[function(require,module,exports){26208 -1 arguments[4][53][0].apply(exports,arguments)26209 -1 },{"./end-of-stream":180,"_process":149,"dup":53}],178:[function(require,module,exports){26210 -1 arguments[4][54][0].apply(exports,arguments)26211 -1 },{"buffer":63,"dup":54,"util":19}],179:[function(require,module,exports){26212 -1 arguments[4][55][0].apply(exports,arguments)26213 -1 },{"_process":149,"dup":55}],180:[function(require,module,exports){26214 -1 arguments[4][56][0].apply(exports,arguments)26215 -1 },{"../../../errors":171,"dup":56}],181:[function(require,module,exports){26216 -1 arguments[4][57][0].apply(exports,arguments)26217 -1 },{"dup":57}],182:[function(require,module,exports){26218 -1 arguments[4][58][0].apply(exports,arguments)26219 -1 },{"../../../errors":171,"./end-of-stream":180,"dup":58}],183:[function(require,module,exports){26220 -1 arguments[4][59][0].apply(exports,arguments)26221 -1 },{"../../../errors":171,"dup":59}],184:[function(require,module,exports){26222 -1 arguments[4][60][0].apply(exports,arguments)26223 -1 },{"dup":60,"events":100}],185:[function(require,module,exports){26224 -1 // Copyright Joyent, Inc. and other Node contributors.26225 -1 //26226 -1 // Permission is hereby granted, free of charge, to any person obtaining a26227 -1 // copy of this software and associated documentation files (the26228 -1 // "Software"), to deal in the Software without restriction, including26229 -1 // without limitation the rights to use, copy, modify, merge, publish,26230 -1 // distribute, sublicense, and/or sell copies of the Software, and to permit26231 -1 // persons to whom the Software is furnished to do so, subject to the26232 -1 // following conditions:26233 -1 //26234 -1 // The above copyright notice and this permission notice shall be included26235 -1 // in all copies or substantial portions of the Software.26236 -1 //26237 -1 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS26238 -1 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF26239 -1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN26240 -1 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,26241 -1 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR26242 -1 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE26243 -1 // USE OR OTHER DEALINGS IN THE SOFTWARE.26244 -126245 -1 'use strict';26246 -126247 -1 /*<replacement>*/26248 -126249 -1 var Buffer = require('safe-buffer').Buffer;26250 -1 /*</replacement>*/26251 -126252 -1 var isEncoding = Buffer.isEncoding || function (encoding) {26253 -1 encoding = '' + encoding;26254 -1 switch (encoding && encoding.toLowerCase()) {26255 -1 case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':26256 -1 return true;26257 -1 default:26258 -1 return false;26259 -1 }26260 -1 };26261 -126262 -1 function _normalizeEncoding(enc) {26263 -1 if (!enc) return 'utf8';26264 -1 var retried;26265 -1 while (true) {26266 -1 switch (enc) {26267 -1 case 'utf8':26268 -1 case 'utf-8':26269 -1 return 'utf8';26270 -1 case 'ucs2':26271 -1 case 'ucs-2':26272 -1 case 'utf16le':26273 -1 case 'utf-16le':26274 -1 return 'utf16le';26275 -1 case 'latin1':26276 -1 case 'binary':26277 -1 return 'latin1';26278 -1 case 'base64':26279 -1 case 'ascii':26280 -1 case 'hex':26281 -1 return enc;26282 -1 default:26283 -1 if (retried) return; // undefined26284 -1 enc = ('' + enc).toLowerCase();26285 -1 retried = true;26286 -1 }26287 -1 }26288 -1 };26289 -126290 -1 // Do not cache `Buffer.isEncoding` when checking encoding names as some26291 -1 // modules monkey-patch it to support additional encodings26292 -1 function normalizeEncoding(enc) {26293 -1 var nenc = _normalizeEncoding(enc);26294 -1 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);26295 -1 return nenc || enc;26296 -1 }26297 -126298 -1 // StringDecoder provides an interface for efficiently splitting a series of26299 -1 // buffers into a series of JS strings without breaking apart multi-byte26300 -1 // characters.26301 -1 exports.StringDecoder = StringDecoder;26302 -1 function StringDecoder(encoding) {26303 -1 this.encoding = normalizeEncoding(encoding);26304 -1 var nb;26305 -1 switch (this.encoding) {26306 -1 case 'utf16le':26307 -1 this.text = utf16Text;26308 -1 this.end = utf16End;26309 -1 nb = 4;26310 -1 break;26311 -1 case 'utf8':26312 -1 this.fillLast = utf8FillLast;26313 -1 nb = 4;26314 -1 break;26315 -1 case 'base64':26316 -1 this.text = base64Text;26317 -1 this.end = base64End;26318 -1 nb = 3;26319 -1 break;26320 -1 default:26321 -1 this.write = simpleWrite;26322 -1 this.end = simpleEnd;26323 -1 return;26324 -1 }26325 -1 this.lastNeed = 0;26326 -1 this.lastTotal = 0;26327 -1 this.lastChar = Buffer.allocUnsafe(nb);26328 -1 }26329 -126330 -1 StringDecoder.prototype.write = function (buf) {26331 -1 if (buf.length === 0) return '';26332 -1 var r;26333 -1 var i;26334 -1 if (this.lastNeed) {26335 -1 r = this.fillLast(buf);26336 -1 if (r === undefined) return '';26337 -1 i = this.lastNeed;26338 -1 this.lastNeed = 0;26339 -1 } else {26340 -1 i = 0;26341 -1 }26342 -1 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);26343 -1 return r || '';26344 -1 };26345 -126346 -1 StringDecoder.prototype.end = utf8End;26347 -126348 -1 // Returns only complete characters in a Buffer26349 -1 StringDecoder.prototype.text = utf8Text;26350 -126351 -1 // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer26352 -1 StringDecoder.prototype.fillLast = function (buf) {26353 -1 if (this.lastNeed <= buf.length) {26354 -1 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);26355 -1 return this.lastChar.toString(this.encoding, 0, this.lastTotal);26356 -1 }26357 -1 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);26358 -1 this.lastNeed -= buf.length;26359 -1 };26360 -126361 -1 // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a26362 -1 // continuation byte. If an invalid byte is detected, -2 is returned.26363 -1 function utf8CheckByte(byte) {26364 -1 if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;26365 -1 return byte >> 6 === 0x02 ? -1 : -2;26366 -1 }26367 -126368 -1 // Checks at most 3 bytes at the end of a Buffer in order to detect an26369 -1 // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)26370 -1 // needed to complete the UTF-8 character (if applicable) are returned.26371 -1 function utf8CheckIncomplete(self, buf, i) {26372 -1 var j = buf.length - 1;26373 -1 if (j < i) return 0;26374 -1 var nb = utf8CheckByte(buf[j]);26375 -1 if (nb >= 0) {26376 -1 if (nb > 0) self.lastNeed = nb - 1;26377 -1 return nb;26378 -1 }26379 -1 if (--j < i || nb === -2) return 0;26380 -1 nb = utf8CheckByte(buf[j]);26381 -1 if (nb >= 0) {26382 -1 if (nb > 0) self.lastNeed = nb - 2;26383 -1 return nb;26384 -1 }26385 -1 if (--j < i || nb === -2) return 0;26386 -1 nb = utf8CheckByte(buf[j]);26387 -1 if (nb >= 0) {26388 -1 if (nb > 0) {26389 -1 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;26390 -1 }26391 -1 return nb;26392 -1 }26393 -1 return 0;26394 -1 }26395 -126396 -1 // Validates as many continuation bytes for a multi-byte UTF-8 character as26397 -1 // needed or are available. If we see a non-continuation byte where we expect26398 -1 // one, we "replace" the validated continuation bytes we've seen so far with26399 -1 // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding26400 -1 // behavior. The continuation byte check is included three times in the case26401 -1 // where all of the continuation bytes for a character exist in the same buffer.26402 -1 // It is also done this way as a slight performance increase instead of using a26403 -1 // loop.26404 -1 function utf8CheckExtraBytes(self, buf, p) {26405 -1 if ((buf[0] & 0xC0) !== 0x80) {26406 -1 self.lastNeed = 0;26407 -1 return '\ufffd';26408 -1 }26409 -1 if (self.lastNeed > 1 && buf.length > 1) {26410 -1 if ((buf[1] & 0xC0) !== 0x80) {26411 -1 self.lastNeed = 1;26412 -1 return '\ufffd';26413 -1 }26414 -1 if (self.lastNeed > 2 && buf.length > 2) {26415 -1 if ((buf[2] & 0xC0) !== 0x80) {26416 -1 self.lastNeed = 2;26417 -1 return '\ufffd';26418 -1 }26419 -1 }26420 -1 }26421 -1 }26422 -126423 -1 // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.26424 -1 function utf8FillLast(buf) {26425 -1 var p = this.lastTotal - this.lastNeed;26426 -1 var r = utf8CheckExtraBytes(this, buf, p);26427 -1 if (r !== undefined) return r;26428 -1 if (this.lastNeed <= buf.length) {26429 -1 buf.copy(this.lastChar, p, 0, this.lastNeed);26430 -1 return this.lastChar.toString(this.encoding, 0, this.lastTotal);26431 -1 }26432 -1 buf.copy(this.lastChar, p, 0, buf.length);26433 -1 this.lastNeed -= buf.length;26434 -1 }26435 -126436 -1 // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a26437 -1 // partial character, the character's bytes are buffered until the required26438 -1 // number of bytes are available.26439 -1 function utf8Text(buf, i) {26440 -1 var total = utf8CheckIncomplete(this, buf, i);26441 -1 if (!this.lastNeed) return buf.toString('utf8', i);26442 -1 this.lastTotal = total;26443 -1 var end = buf.length - (total - this.lastNeed);26444 -1 buf.copy(this.lastChar, 0, end);26445 -1 return buf.toString('utf8', i, end);26446 -1 }26447 -126448 -1 // For UTF-8, a replacement character is added when ending on a partial26449 -1 // character.26450 -1 function utf8End(buf) {26451 -1 var r = buf && buf.length ? this.write(buf) : '';26452 -1 if (this.lastNeed) return r + '\ufffd';26453 -1 return r;26454 -1 }26455 -126456 -1 // UTF-16LE typically needs two bytes per character, but even if we have an even26457 -1 // number of bytes available, we need to check if we end on a leading/high26458 -1 // surrogate. In that case, we need to wait for the next two bytes in order to26459 -1 // decode the last character properly.26460 -1 function utf16Text(buf, i) {26461 -1 if ((buf.length - i) % 2 === 0) {26462 -1 var r = buf.toString('utf16le', i);26463 -1 if (r) {26464 -1 var c = r.charCodeAt(r.length - 1);26465 -1 if (c >= 0xD800 && c <= 0xDBFF) {26466 -1 this.lastNeed = 2;26467 -1 this.lastTotal = 4;26468 -1 this.lastChar[0] = buf[buf.length - 2];26469 -1 this.lastChar[1] = buf[buf.length - 1];26470 -1 return r.slice(0, -1);26471 -1 }26472 -1 }26473 -1 return r;26474 -1 }26475 -1 this.lastNeed = 1;26476 -1 this.lastTotal = 2;26477 -1 this.lastChar[0] = buf[buf.length - 1];26478 -1 return buf.toString('utf16le', i, buf.length - 1);26479 -1 }26480 -126481 -1 // For UTF-16LE we do not explicitly append special replacement characters if we26482 -1 // end on a partial character, we simply let v8 handle that.26483 -1 function utf16End(buf) {26484 -1 var r = buf && buf.length ? this.write(buf) : '';26485 -1 if (this.lastNeed) {26486 -1 var end = this.lastTotal - this.lastNeed;26487 -1 return r + this.lastChar.toString('utf16le', 0, end);26488 -1 }26489 -1 return r;26490 -1 }26491 -126492 -1 function base64Text(buf, i) {26493 -1 var n = (buf.length - i) % 3;26494 -1 if (n === 0) return buf.toString('base64', i);26495 -1 this.lastNeed = 3 - n;26496 -1 this.lastTotal = 3;26497 -1 if (n === 1) {26498 -1 this.lastChar[0] = buf[buf.length - 1];26499 -1 } else {26500 -1 this.lastChar[0] = buf[buf.length - 2];26501 -1 this.lastChar[1] = buf[buf.length - 1];26502 -1 }26503 -1 return buf.toString('base64', i, buf.length - n);26504 -1 }26505 -126506 -1 function base64End(buf) {26507 -1 var r = buf && buf.length ? this.write(buf) : '';26508 -1 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);26509 -1 return r;26510 -1 }26511 -126512 -1 // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)26513 -1 function simpleWrite(buf) {26514 -1 return buf.toString(this.encoding);26515 -1 }26516 -126517 -1 function simpleEnd(buf) {26518 -1 return buf && buf.length ? this.write(buf) : '';26519 -1 }26520 -1 },{"safe-buffer":160}],186:[function(require,module,exports){26521 -1 (function (setImmediate,clearImmediate){(function (){26522 -1 var nextTick = require('process/browser.js').nextTick;26523 -1 var apply = Function.prototype.apply;26524 -1 var slice = Array.prototype.slice;26525 -1 var immediateIds = {};26526 -1 var nextImmediateId = 0;26527 -126528 -1 // DOM APIs, for completeness26529 -126530 -1 exports.setTimeout = function() {26531 -1 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);26532 -1 };26533 -1 exports.setInterval = function() {26534 -1 return new Timeout(apply.call(setInterval, window, arguments), clearInterval);26535 -1 };26536 -1 exports.clearTimeout =26537 -1 exports.clearInterval = function(timeout) { timeout.close(); };26538 -126539 -1 function Timeout(id, clearFn) {26540 -1 this._id = id;26541 -1 this._clearFn = clearFn;26542 -1 }26543 -1 Timeout.prototype.unref = Timeout.prototype.ref = function() {};26544 -1 Timeout.prototype.close = function() {26545 -1 this._clearFn.call(window, this._id);26546 -1 };26547 -126548 -1 // Does not start the time, just sets up the members needed.26549 -1 exports.enroll = function(item, msecs) {26550 -1 clearTimeout(item._idleTimeoutId);26551 -1 item._idleTimeout = msecs;26552 -1 };26553 -126554 -1 exports.unenroll = function(item) {26555 -1 clearTimeout(item._idleTimeoutId);26556 -1 item._idleTimeout = -1;26557 -1 };26558 -126559 -1 exports._unrefActive = exports.active = function(item) {26560 -1 clearTimeout(item._idleTimeoutId);26561 -126562 -1 var msecs = item._idleTimeout;26563 -1 if (msecs >= 0) {26564 -1 item._idleTimeoutId = setTimeout(function onTimeout() {26565 -1 if (item._onTimeout)26566 -1 item._onTimeout();26567 -1 }, msecs);26568 -1 }26569 -1 };26570 -126571 -1 // That's not how node.js implements it but the exposed api is the same.26572 -1 exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {26573 -1 var id = nextImmediateId++;26574 -1 var args = arguments.length < 2 ? false : slice.call(arguments, 1);26575 -126576 -1 immediateIds[id] = true;26577 -126578 -1 nextTick(function onNextTick() {26579 -1 if (immediateIds[id]) {26580 -1 // fn.call() is faster so we optimize for the common use-case26581 -1 // @see http://jsperf.com/call-apply-segu26582 -1 if (args) {26583 -1 fn.apply(null, args);26584 -1 } else {26585 -1 fn.call(null);26586 -1 }26587 -1 // Prevent ids from leaking26588 -1 exports.clearImmediate(id);26589 -1 }26590 -1 });26591 -126592 -1 return id;26593 -1 };26594 -126595 -1 exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {26596 -1 delete immediateIds[id];26597 -1 };26598 -1 }).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate)26599 -1 },{"process/browser.js":149,"timers":186}],187:[function(require,module,exports){26600 -1 (function (global){(function (){26601 -126602 -1 /**26603 -1 * Module exports.26604 -1 */26605 -126606 -1 module.exports = deprecate;26607 -126608 -1 /**26609 -1 * Mark that a method should not be used.26610 -1 * Returns a modified function which warns once by default.26611 -1 *26612 -1 * If `localStorage.noDeprecation = true` is set, then it is a no-op.26613 -1 *26614 -1 * If `localStorage.throwDeprecation = true` is set, then deprecated functions26615 -1 * will throw an Error when invoked.26616 -1 *26617 -1 * If `localStorage.traceDeprecation = true` is set, then deprecated functions26618 -1 * will invoke `console.trace()` instead of `console.error()`.26619 -1 *26620 -1 * @param {Function} fn - the function to deprecate26621 -1 * @param {String} msg - the string to print to the console when `fn` is invoked26622 -1 * @returns {Function} a new "deprecated" version of `fn`26623 -1 * @api public26624 -1 */26625 -126626 -1 function deprecate (fn, msg) {26627 -1 if (config('noDeprecation')) {26628 -1 return fn;26629 -1 }26630 -126631 -1 var warned = false;26632 -1 function deprecated() {26633 -1 if (!warned) {26634 -1 if (config('throwDeprecation')) {26635 -1 throw new Error(msg);26636 -1 } else if (config('traceDeprecation')) {26637 -1 console.trace(msg);26638 -1 } else {26639 -1 console.warn(msg);26640 -1 }26641 -1 warned = true;26642 -1 }26643 -1 return fn.apply(this, arguments);26644 -1 }26645 -126646 -1 return deprecated;26647 -1 }26648 -126649 -1 /**26650 -1 * Checks `localStorage` for boolean values for the given `name`.26651 -1 *26652 -1 * @param {String} name26653 -1 * @returns {Boolean}26654 -1 * @api private26655 -1 */26656 -126657 -1 function config (name) {26658 -1 // accessing global.localStorage can trigger a DOMException in sandboxed iframes26659 -1 try {26660 -1 if (!global.localStorage) return false;26661 -1 } catch (_) {26662 -1 return false;26663 -1 }26664 -1 var val = global.localStorage[name];26665 -1 if (null == val) return false;26666 -1 return String(val).toLowerCase() === 'true';26667 -1 }26668 -126669 -1 }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})26670 -1 },{}],188:[function(require,module,exports){26671 -1 // Copyright 2012 Google Inc.26672 -1 //26673 -1 // Licensed under the Apache License, Version 2.0 (the "License");26674 -1 // you may not use this file except in compliance with the License.26675 -1 // You may obtain a copy of the License at26676 -1 //26677 -1 // http://www.apache.org/licenses/LICENSE-2.026678 -1 //26679 -1 // Unless required by applicable law or agreed to in writing, software26680 -1 // distributed under the License is distributed on an "AS IS" BASIS,26681 -1 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.26682 -1 // See the License for the specific language governing permissions and26683 -1 // limitations under the License.26684 -126685 -1 goog.require('axs.browserUtils');26686 -1 goog.require('axs.color');26687 -1 goog.require('axs.color.Color');26688 -1 goog.require('axs.constants');26689 -1 goog.require('axs.dom');26690 -126691 -1 goog.provide('axs.utils');26692 -126693 -1 /**26694 -1 * @const26695 -1 * @type {string}26696 -1 */26697 -1 axs.utils.FOCUSABLE_ELEMENTS_SELECTOR =26698 -1 'input:not([type=hidden]):not([disabled]),' +26699 -1 'select:not([disabled]),' +26700 -1 'textarea:not([disabled]),' +26701 -1 'button:not([disabled]),' +26702 -1 'a[href],' +26703 -1 'iframe,' +26704 -1 '[tabindex]';26705 -126706 -1 /**26707 -1 * Elements that can have labels: https://html.spec.whatwg.org/multipage/forms.html#category-label26708 -1 * @const26709 -1 * @type {string}26710 -1 */26711 -1 axs.utils.LABELABLE_ELEMENTS_SELECTOR =26712 -1 'button,' +26713 -1 'input:not([type=hidden]),' +26714 -1 'keygen,' +26715 -1 'meter,' +26716 -1 'output,' +26717 -1 'progress,' +26718 -1 'select,' +26719 -1 'textarea';26720 -126721 -126722 -1 /**26723 -1 * @param {Element} element26724 -1 * @return {boolean}26725 -1 */26726 -1 axs.utils.elementIsTransparent = function(element) {26727 -1 return element.style.opacity == '0';26728 -1 };26729 -126730 -1 /**26731 -1 * @param {Element} element26732 -1 * @return {boolean}26733 -1 */26734 -1 axs.utils.elementHasZeroArea = function(element) {26735 -1 var rect = element.getBoundingClientRect();26736 -1 var width = rect.right - rect.left;26737 -1 var height = rect.top - rect.bottom;26738 -1 if (!width || !height)26739 -1 return true;26740 -1 return false;26741 -1 };26742 -126743 -1 /**26744 -1 * @param {Element} element26745 -1 * @return {boolean}26746 -1 */26747 -1 axs.utils.elementIsOutsideScrollArea = function(element) {26748 -1 var parent = axs.dom.parentElement(element);26749 -126750 -1 var defaultView = element.ownerDocument.defaultView;26751 -1 while (parent != defaultView.document.body) {26752 -1 if (axs.utils.isClippedBy(element, parent))26753 -1 return true;26754 -126755 -1 if (axs.utils.canScrollTo(element, parent) && !axs.utils.elementIsOutsideScrollArea(parent))26756 -1 return false;26757 -126758 -1 parent = axs.dom.parentElement(parent);26759 -1 }26760 -126761 -1 return !axs.utils.canScrollTo(element, defaultView.document.body);26762 -1 };26763 -126764 -1 /**26765 -1 * Checks whether it's possible to scroll to the given element within the given container.26766 -1 * Assumes that |container| is an ancestor of |element|.26767 -1 * If |container| cannot be scrolled, returns True if the element is within its bounding client26768 -1 * rect.26769 -1 * @param {Element} element26770 -1 * @param {Element} container26771 -1 * @return {boolean} True iff it's possible to scroll to |element| within |container|.26772 -1 */26773 -1 axs.utils.canScrollTo = function(element, container) {26774 -1 var rect = element.getBoundingClientRect();26775 -1 var containerRect = container.getBoundingClientRect();26776 -1 if (container == container.ownerDocument.body) {26777 -1 var absoluteTop = containerRect.top;26778 -1 var absoluteLeft = containerRect.left;26779 -1 } else {26780 -1 var absoluteTop = containerRect.top - container.scrollTop;26781 -1 var absoluteLeft = containerRect.left - container.scrollLeft;26782 -1 }26783 -1 var containerScrollArea =26784 -1 { top: absoluteTop,26785 -1 bottom: absoluteTop + container.scrollHeight,26786 -1 left: absoluteLeft,26787 -1 right: absoluteLeft + container.scrollWidth };26788 -126789 -1 if (rect.right < containerScrollArea.left || rect.bottom < containerScrollArea.top ||26790 -1 rect.left > containerScrollArea.right || rect.top > containerScrollArea.bottom) {26791 -1 return false;26792 -1 }26793 -126794 -1 var defaultView = element.ownerDocument.defaultView;26795 -1 var style = defaultView.getComputedStyle(container);26796 -126797 -1 if (rect.left > containerRect.right || rect.top > containerRect.bottom) {26798 -1 return (style.overflow == 'scroll' || style.overflow == 'auto' ||26799 -1 container instanceof defaultView.HTMLBodyElement);26800 -1 }26801 -126802 -1 return true;26803 -1 };26804 -126805 -1 /**26806 -1 * Checks whether the given element is clipped by the given container.26807 -1 * Assumes that |container| is an ancestor of |element|.26808 -1 * @param {Element} element26809 -1 * @param {Element} container26810 -1 * @return {boolean} True iff |element| is clipped by |container|.26811 -1 */26812 -1 axs.utils.isClippedBy = function(element, container) {26813 -1 var rect = element.getBoundingClientRect();26814 -1 var containerRect = container.getBoundingClientRect();26815 -1 var containerTop = containerRect.top;26816 -1 var containerLeft = containerRect.left;26817 -1 var containerScrollArea =26818 -1 { top: containerTop - container.scrollTop,26819 -1 bottom: containerTop - container.scrollTop + container.scrollHeight,26820 -1 left: containerLeft - container.scrollLeft,26821 -1 right: containerLeft - container.scrollLeft + container.scrollWidth };26822 -126823 -1 var defaultView = element.ownerDocument.defaultView;26824 -1 var style = defaultView.getComputedStyle(container);26825 -126826 -1 if ((rect.right < containerRect.left || rect.bottom < containerRect.top ||26827 -1 rect.left > containerRect.right || rect.top > containerRect.bottom) &&26828 -1 style.overflow == 'hidden') {26829 -1 return true;26830 -1 }26831 -126832 -1 if (rect.right < containerScrollArea.left || rect.bottom < containerScrollArea.top)26833 -1 return (style.overflow != 'visible');26834 -126835 -1 return false;26836 -1 };26837 -126838 -1 /**26839 -1 * @param {Node} ancestor A potential ancestor of |node|.26840 -1 * @param {Node} node26841 -1 * @return {boolean} true if |ancestor| is an ancestor of |node| (including26842 -1 * |ancestor| === |node|).26843 -1 */26844 -1 axs.utils.isAncestor = function(ancestor, node) {26845 -1 if (node == null)26846 -1 return false;26847 -1 if (node === ancestor)26848 -1 return true;26849 -126850 -1 var parentNode = axs.dom.composedParentNode(node);26851 -1 return axs.utils.isAncestor(ancestor, parentNode);26852 -1 };26853 -126854 -1 /**26855 -1 * @param {Element} element26856 -1 * @return {Array.<Element>} An array of any non-transparent elements which26857 -1 * overlap the given element.26858 -1 */26859 -1 axs.utils.overlappingElements = function(element) {26860 -1 if (axs.utils.elementHasZeroArea(element))26861 -1 return null;26862 -126863 -1 var overlappingElements = [];26864 -1 var clientRects = element.getClientRects();26865 -1 for (var i = 0; i < clientRects.length; i++) {26866 -1 var rect = clientRects[i];26867 -1 var center_x = (rect.left + rect.right) / 2;26868 -1 var center_y = (rect.top + rect.bottom) / 2;26869 -1 var elementAtPoint = document.elementFromPoint(center_x, center_y);26870 -126871 -1 if (elementAtPoint == null || elementAtPoint == element ||26872 -1 axs.utils.isAncestor(elementAtPoint, element) ||26873 -1 axs.utils.isAncestor(element, elementAtPoint)) {26874 -1 continue;26875 -1 }26876 -126877 -1 var overlappingElementStyle = window.getComputedStyle(elementAtPoint, null);26878 -1 if (!overlappingElementStyle)26879 -1 continue;26880 -126881 -1 var overlappingElementBg = axs.utils.getBgColor(overlappingElementStyle,26882 -1 elementAtPoint);26883 -1 if (overlappingElementBg && overlappingElementBg.alpha > 0 &&26884 -1 overlappingElements.indexOf(elementAtPoint) < 0) {26885 -1 overlappingElements.push(elementAtPoint);26886 -1 }26887 -1 }26888 -126889 -1 return overlappingElements;26890 -1 };26891 -126892 -1 /**26893 -1 * @param {Element} element26894 -1 * @return {boolean}26895 -1 */26896 -1 axs.utils.elementIsHtmlControl = function(element) {26897 -1 var defaultView = element.ownerDocument.defaultView;26898 -126899 -1 // HTML control26900 -1 if (element instanceof defaultView.HTMLButtonElement)26901 -1 return true;26902 -1 if (element instanceof defaultView.HTMLInputElement)26903 -1 return true;26904 -1 if (element instanceof defaultView.HTMLSelectElement)26905 -1 return true;26906 -1 if (element instanceof defaultView.HTMLTextAreaElement)26907 -1 return true;26908 -126909 -1 return false;26910 -1 };26911 -126912 -1 /**26913 -1 * @param {Element} element26914 -1 * @return {boolean}26915 -1 */26916 -1 axs.utils.elementIsAriaWidget = function(element) {26917 -1 if (element.hasAttribute('role')) {26918 -1 var roleValue = element.getAttribute('role');26919 -1 // TODO is this correct?26920 -1 if (roleValue) {26921 -1 var role = axs.constants.ARIA_ROLES[roleValue];26922 -1 if (role && 'widget' in role['allParentRolesSet'])26923 -1 return true;26924 -1 }26925 -1 }26926 -1 return false;26927 -1 };26928 -126929 -1 /**26930 -1 * @param {Element} element26931 -1 * @return {boolean}26932 -1 */26933 -1 axs.utils.elementIsVisible = function(element) {26934 -1 if (axs.utils.elementIsTransparent(element))26935 -1 return false;26936 -1 if (axs.utils.elementHasZeroArea(element))26937 -1 return false;26938 -1 if (axs.utils.elementIsOutsideScrollArea(element))26939 -1 return false;26940 -126941 -1 var overlappingElements = axs.utils.overlappingElements(element);26942 -1 if (overlappingElements.length)26943 -1 return false;26944 -126945 -1 return true;26946 -1 };26947 -126948 -1 /**26949 -1 * @param {CSSStyleDeclaration} style26950 -1 * @return {boolean}26951 -1 */26952 -1 axs.utils.isLargeFont = function(style) {26953 -1 var fontSize = style.fontSize;26954 -1 var bold = style.fontWeight == 'bold';26955 -1 var matches = fontSize.match(/(\d+)px/);26956 -1 if (matches) {26957 -1 var fontSizePx = parseInt(matches[1], 10);26958 -1 var bodyStyle = window.getComputedStyle(document.body, null);26959 -1 var bodyFontSize = bodyStyle.fontSize;26960 -1 matches = bodyFontSize.match(/(\d+)px/);26961 -1 if (matches) {26962 -1 var bodyFontSizePx = parseInt(matches[1], 10);26963 -1 var boldLarge = bodyFontSizePx * 1.2;26964 -1 var large = bodyFontSizePx * 1.5;26965 -1 } else {26966 -1 var boldLarge = 19.2;26967 -1 var large = 24;26968 -1 }26969 -1 return (bold && fontSizePx >= boldLarge || fontSizePx >= large);26970 -1 }26971 -1 matches = fontSize.match(/(\d+)em/);26972 -1 if (matches) {26973 -1 var fontSizeEm = parseInt(matches[1], 10);26974 -1 if (bold && fontSizeEm >= 1.2 || fontSizeEm >= 1.5)26975 -1 return true;26976 -1 return false;26977 -1 }26978 -1 matches = fontSize.match(/(\d+)%/);26979 -1 if (matches) {26980 -1 var fontSizePercent = parseInt(matches[1], 10);26981 -1 if (bold && fontSizePercent >= 120 || fontSizePercent >= 150)26982 -1 return true;26983 -1 return false;26984 -1 }26985 -1 matches = fontSize.match(/(\d+)pt/);26986 -1 if (matches) {26987 -1 var fontSizePt = parseInt(matches[1], 10);26988 -1 if (bold && fontSizePt >= 14 || fontSizePt >= 18)26989 -1 return true;26990 -1 return false;26991 -1 }26992 -1 return false;26993 -1 };26994 -126995 -1 /**26996 -1 * @param {CSSStyleDeclaration} style26997 -1 * @param {Element} element26998 -1 * @return {?axs.color.Color}26999 -1 */27000 -1 axs.utils.getBgColor = function(style, element) {27001 -1 var bgColorString = style.backgroundColor;27002 -1 var bgColor = axs.color.parseColor(bgColorString);27003 -1 if (!bgColor)27004 -1 return null;27005 -127006 -1 if (style.opacity < 1)27007 -1 bgColor.alpha = bgColor.alpha * style.opacity;27008 -127009 -1 if (bgColor.alpha < 1) {27010 -1 var parentBg = axs.utils.getParentBgColor(element);27011 -1 if (parentBg == null)27012 -1 return null;27013 -127014 -1 bgColor = axs.color.flattenColors(bgColor, parentBg);27015 -1 }27016 -1 return bgColor;27017 -1 };27018 -127019 -1 /**27020 -1 * Gets the effective background color of the parent of |element|.27021 -1 * @param {Element} element27022 -1 * @return {?axs.color.Color}27023 -1 */27024 -1 axs.utils.getParentBgColor = function(element) {27025 -1 /** @type {Element} */ var parent = element;27026 -1 var bgStack = [];27027 -1 var foundSolidColor = null;27028 -1 while ((parent = axs.dom.parentElement(parent))) {27029 -1 var computedStyle = window.getComputedStyle(parent, null);27030 -1 if (!computedStyle)27031 -1 continue;27032 -127033 -1 var parentBg = axs.color.parseColor(computedStyle.backgroundColor);27034 -1 if (!parentBg)27035 -1 continue;27036 -127037 -1 if (computedStyle.opacity < 1)27038 -1 parentBg.alpha = parentBg.alpha * computedStyle.opacity;27039 -127040 -1 if (parentBg.alpha == 0)27041 -1 continue;27042 -127043 -1 bgStack.push(parentBg);27044 -127045 -1 if (parentBg.alpha == 1) {27046 -1 foundSolidColor = true;27047 -1 break;27048 -1 }27049 -1 }27050 -127051 -1 if (!foundSolidColor)27052 -1 bgStack.push(new axs.color.Color(255, 255, 255, 1));27053 -127054 -1 var bg = bgStack.pop();27055 -1 while (bgStack.length) {27056 -1 var fg = bgStack.pop();27057 -1 bg = axs.color.flattenColors(fg, bg);27058 -1 }27059 -1 return bg;27060 -1 };27061 -127062 -1 /**27063 -1 * @param {CSSStyleDeclaration} style27064 -1 * @param {Element} element27065 -1 * @param {axs.color.Color} bgColor The background color, which may come from27066 -1 * another element (such as a parent element), for flattening into the27067 -1 * foreground color.27068 -1 * @return {?axs.color.Color}27069 -1 */27070 -1 axs.utils.getFgColor = function(style, element, bgColor) {27071 -1 var fgColorString = style.color;27072 -1 var fgColor = axs.color.parseColor(fgColorString);27073 -1 if (!fgColor)27074 -1 return null;27075 -127076 -1 if (fgColor.alpha < 1)27077 -1 fgColor = axs.color.flattenColors(fgColor, bgColor);27078 -127079 -1 if (style.opacity < 1) {27080 -1 var parentBg = axs.utils.getParentBgColor(element);27081 -1 fgColor.alpha = fgColor.alpha * style.opacity;27082 -1 fgColor = axs.color.flattenColors(fgColor, parentBg);27083 -1 }27084 -127085 -1 return fgColor;27086 -1 };27087 -127088 -1 /**27089 -1 * @param {Element} element27090 -1 * @return {?number}27091 -1 */27092 -1 axs.utils.getContrastRatioForElement = function(element) {27093 -1 var style = window.getComputedStyle(element, null);27094 -1 return axs.utils.getContrastRatioForElementWithComputedStyle(style, element);27095 -1 };27096 -127097 -1 /**27098 -1 * @param {CSSStyleDeclaration} style27099 -1 * @param {Element} element27100 -1 * @return {?number}27101 -1 */27102 -1 axs.utils.getContrastRatioForElementWithComputedStyle = function(style, element) {27103 -1 if (axs.utils.isElementHidden(element))27104 -1 return null;27105 -127106 -1 var bgColor = axs.utils.getBgColor(style, element);27107 -1 if (!bgColor)27108 -1 return null;27109 -127110 -1 var fgColor = axs.utils.getFgColor(style, element, bgColor);27111 -1 if (!fgColor)27112 -1 return null;27113 -127114 -1 return axs.color.calculateContrastRatio(fgColor, bgColor);27115 -1 };27116 -127117 -1 /**27118 -1 * @param {Element} element27119 -1 * @return {boolean}27120 -1 */27121 -1 axs.utils.isNativeTextElement = function(element) {27122 -1 var tagName = element.tagName.toLowerCase();27123 -1 var type = element.type ? element.type.toLowerCase() : '';27124 -1 if (tagName == 'textarea')27125 -1 return true;27126 -1 if (tagName != 'input')27127 -1 return false;27128 -127129 -1 switch (type) {27130 -1 case 'email':27131 -1 case 'number':27132 -1 case 'password':27133 -1 case 'search':27134 -1 case 'text':27135 -1 case 'tel':27136 -1 case 'url':27137 -1 case '':27138 -1 return true;27139 -1 default:27140 -1 return false;27141 -1 }27142 -1 };27143 -127144 -1 /**27145 -1 * @param {number} contrastRatio27146 -1 * @param {CSSStyleDeclaration} style27147 -1 * @param {boolean=} opt_strict Whether to use AA (false) or AAA (true) level27148 -1 * @return {boolean}27149 -1 */27150 -1 axs.utils.isLowContrast = function(contrastRatio, style, opt_strict) {27151 -1 // Round to nearest 0.127152 -1 var roundedContrastRatio = (Math.round(contrastRatio * 10) / 10);27153 -1 if (!opt_strict) {27154 -1 return roundedContrastRatio < 3.0 ||27155 -1 (!axs.utils.isLargeFont(style) && roundedContrastRatio < 4.5);27156 -1 } else {27157 -1 return roundedContrastRatio < 4.5 ||27158 -1 (!axs.utils.isLargeFont(style) && roundedContrastRatio < 7.0);27159 -1 }27160 -1 };27161 -127162 -1 /**27163 -1 * @param {Element} element27164 -1 * @return {boolean}27165 -1 */27166 -1 axs.utils.hasLabel = function(element) {27167 -1 var tagName = element.tagName.toLowerCase();27168 -1 var type = element.type ? element.type.toLowerCase() : '';27169 -127170 -1 if (element.hasAttribute('aria-label'))27171 -1 return true;27172 -1 if (element.hasAttribute('title'))27173 -1 return true;27174 -1 if (tagName == 'img' && element.hasAttribute('alt'))27175 -1 return true;27176 -1 if (tagName == 'input' && type == 'image' && element.hasAttribute('alt'))27177 -1 return true;27178 -1 if (tagName == 'input' && (type == 'submit' || type == 'reset'))27179 -1 return true;27180 -127181 -1 // There's a separate audit that makes sure this points to an actual element or elements.27182 -1 if (element.hasAttribute('aria-labelledby'))27183 -1 return true;27184 -127185 -1 if (element.hasAttribute('id')) {27186 -1 var labelsFor = document.querySelectorAll('label[for="' + element.id + '"]');27187 -1 if (labelsFor.length > 0)27188 -1 return true;27189 -1 }27190 -127191 -1 var parent = axs.dom.parentElement(element);27192 -1 while (parent) {27193 -1 if (parent.tagName.toLowerCase() == 'label') {27194 -1 var parentLabel = /** HTMLLabelElement */ parent;27195 -1 if (parentLabel.control == element)27196 -1 return true;27197 -1 }27198 -1 parent = axs.dom.parentElement(parent);27199 -1 }27200 -1 return false;27201 -1 };27202 -127203 -1 /**27204 -1 * Determine if this element natively supports being disabled (i.e. via the `disabled` attribute.27205 -1 * Disabled here means that the element should be considered disabled according to specification.27206 -1 * This element may or may not be effectively disabled in practice as this is dependent on implementation.27207 -1 *27208 -1 * @param {Element} element An element to check.27209 -1 * @return {boolean} true If the element supports being natively disabled.27210 -1 */27211 -1 axs.utils.isNativelyDisableable = function(element) {27212 -1 var tagName = element.tagName.toUpperCase();27213 -1 return (tagName in axs.constants.NATIVELY_DISABLEABLE);27214 -1 };27215 -127216 -1 /**27217 -1 * Determine if this element is disabled directly or indirectly by a disabled ancestor.27218 -1 * Disabled here means that the element should be considered disabled according to specification.27219 -1 * This element may or may not be effectively disabled in practice as this is dependent on implementation.27220 -1 *27221 -1 * @param {Element} element An element to check.27222 -1 * @param {boolean=} ignoreAncestors If true do not check for disabled ancestors.27223 -1 * @return {boolean} true if the element or one of its ancestors is disabled.27224 -1 */27225 -1 axs.utils.isElementDisabled = function(element, ignoreAncestors) {27226 -1 var selector = ignoreAncestors ? '[aria-disabled=true]' : '[aria-disabled=true], [aria-disabled=true] *';27227 -1 if (axs.browserUtils.matchSelector(element, selector)) {27228 -1 return true;27229 -1 }27230 -1 if (!axs.utils.isNativelyDisableable(element) ||27231 -1 axs.browserUtils.matchSelector(element, 'fieldset>legend:first-of-type *')) {27232 -1 return false;27233 -1 }27234 -1 for (var next = element; next !== null; next = axs.dom.parentElement(next)) {27235 -1 if (next.hasAttribute('disabled')) {27236 -1 return true;27237 -1 }27238 -1 if (ignoreAncestors) {27239 -1 return false;27240 -1 }27241 -1 }27242 -1 return false;27243 -1 };27244 -127245 -1 /**27246 -1 * @param {Element} element An element to check.27247 -1 * @return {boolean} True if the element is hidden from accessibility.27248 -1 */27249 -1 axs.utils.isElementHidden = function(element) {27250 -1 if (!(element instanceof element.ownerDocument.defaultView.HTMLElement))27251 -1 return false;27252 -127253 -1 if (element.hasAttribute('chromevoxignoreariahidden'))27254 -1 var chromevoxignoreariahidden = true;27255 -127256 -1 var style = window.getComputedStyle(element, null);27257 -1 if (style.display == 'none' || style.visibility == 'hidden')27258 -1 return true;27259 -127260 -1 if (element.hasAttribute('aria-hidden') &&27261 -1 element.getAttribute('aria-hidden').toLowerCase() == 'true') {27262 -1 return !chromevoxignoreariahidden;27263 -1 }27264 -127265 -1 return false;27266 -1 };27267 -127268 -1 /**27269 -1 * @param {Element} element An element to check.27270 -1 * @return {boolean} True if the element or one of its ancestors is27271 -1 * hidden from accessibility.27272 -1 */27273 -1 axs.utils.isElementOrAncestorHidden = function(element) {27274 -1 if (axs.utils.isElementHidden(element))27275 -1 return true;27276 -127277 -1 if (axs.dom.parentElement(element))27278 -1 return axs.utils.isElementOrAncestorHidden(axs.dom.parentElement(element));27279 -1 else27280 -1 return false;27281 -1 };27282 -127283 -1 /**27284 -1 * @param {Element} element An element to check27285 -1 * @return {boolean} True if the given element is an inline element, false27286 -1 * otherwise.27287 -1 */27288 -1 axs.utils.isInlineElement = function(element) {27289 -1 var tagName = element.tagName.toUpperCase();27290 -1 return axs.constants.InlineElements[tagName];27291 -1 };27292 -127293 -1 /**27294 -1 *27295 -1 * Gets role details from an element.27296 -1 * @param {Element} element The DOM element whose role we want.27297 -1 * @param {boolean=} implicit if true then implicit semantics will be considered if there is no role attribute.27298 -1 *27299 -1 * @return {Object}27300 -1 */27301 -1 axs.utils.getRoles = function(element, implicit) {27302 -1 if (!element || element.nodeType !== Node.ELEMENT_NODE || (!element.hasAttribute('role') && !implicit))27303 -1 return null;27304 -1 var roleValue = element.getAttribute('role');27305 -1 if (!roleValue && implicit)27306 -1 roleValue = axs.properties.getImplicitRole(element);27307 -1 if (!roleValue) // role='' or implicit role came up empty27308 -1 return null;27309 -1 var roleNames = roleValue.split(' ');27310 -1 var result = { roles: [], valid: false };27311 -1 for (var i = 0; i < roleNames.length; i++) {27312 -1 var role = roleNames[i];27313 -1 var ariaRole = axs.constants.ARIA_ROLES[role];27314 -1 var roleObject = { 'name': role };27315 -1 if (ariaRole && !ariaRole.abstract) {27316 -1 roleObject.details = ariaRole;27317 -1 if (!result.applied) {27318 -1 result.applied = roleObject;27319 -1 }27320 -1 roleObject.valid = result.valid = true;27321 -1 } else {27322 -1 roleObject.valid = false;27323 -1 }27324 -1 result.roles.push(roleObject);27325 -1 }27326 -127327 -1 return result;27328 -1 };27329 -127330 -1 /**27331 -1 * @param {!string} propertyName27332 -1 * @param {!string} value27333 -1 * @param {!Element} element27334 -1 * @return {!Object}27335 -1 */27336 -1 axs.utils.getAriaPropertyValue = function(propertyName, value, element) {27337 -1 var propertyKey = propertyName.replace(/^aria-/, '');27338 -1 var property = axs.constants.ARIA_PROPERTIES[propertyKey];27339 -1 var result = { 'name': propertyName, 'rawValue': value };27340 -1 if (!property) {27341 -1 result.valid = false;27342 -1 result.reason = '"' + propertyName + '" is not a valid ARIA property';27343 -1 return result;27344 -1 }27345 -127346 -1 var propertyType = property.valueType;27347 -1 if (!propertyType) {27348 -1 result.valid = false;27349 -1 result.reason = '"' + propertyName + '" is not a valid ARIA property';27350 -1 return result;27351 -1 }27352 -127353 -1 switch (propertyType) {27354 -1 case "idref":27355 -1 var isValid = axs.utils.isValidIDRefValue(value, element);27356 -1 result.valid = isValid.valid;27357 -1 result.reason = isValid.reason;27358 -1 result.idref = isValid.idref;27359 -1 // falls through27360 -1 case "idref_list":27361 -1 var idrefValues = value.split(/\s+/);27362 -1 result.valid = true;27363 -1 for (var i = 0; i < idrefValues.length; i++) {27364 -1 var refIsValid = axs.utils.isValidIDRefValue(idrefValues[i], element);27365 -1 if (!refIsValid.valid)27366 -1 result.valid = false;27367 -1 if (result.values)27368 -1 result.values.push(refIsValid);27369 -1 else27370 -1 result.values = [refIsValid];27371 -1 }27372 -1 return result;27373 -1 case "integer":27374 -1 var validNumber = axs.utils.isValidNumber(value);27375 -1 if (!validNumber.valid) {27376 -1 result.valid = false;27377 -1 result.reason = validNumber.reason;27378 -1 return result;27379 -1 }27380 -1 if (Math.floor(validNumber.value) !== validNumber.value) {27381 -1 result.valid = false;27382 -1 result.reason = '' + value + ' is not a whole integer';27383 -1 } else {27384 -1 result.valid = true;27385 -1 result.value = validNumber.value;27386 -1 }27387 -1 return result;27388 -1 case "decimal":27389 -1 case "number":27390 -1 var validNumber = axs.utils.isValidNumber(value);27391 -1 result.valid = validNumber.valid;27392 -1 if (!validNumber.valid) {27393 -1 result.reason = validNumber.reason;27394 -1 return result;27395 -1 }27396 -1 result.value = validNumber.value;27397 -1 return result;27398 -1 case "string":27399 -1 result.valid = true;27400 -1 result.value = value;27401 -1 return result;27402 -1 case "token":27403 -1 var validTokenValue = axs.utils.isValidTokenValue(propertyName, value.toLowerCase());27404 -1 if (validTokenValue.valid) {27405 -1 result.valid = true;27406 -1 result.value = validTokenValue.value;27407 -1 return result;27408 -1 } else {27409 -1 result.valid = false;27410 -1 result.value = value;27411 -1 result.reason = validTokenValue.reason;27412 -1 return result;27413 -1 }27414 -1 // falls through27415 -1 case "token_list":27416 -1 var tokenValues = value.split(/\s+/);27417 -1 result.valid = true;27418 -1 for (var i = 0; i < tokenValues.length; i++) {27419 -1 var validTokenValue = axs.utils.isValidTokenValue(propertyName, tokenValues[i].toLowerCase());27420 -1 if (!validTokenValue.valid) {27421 -1 result.valid = false;27422 -1 if (result.reason) {27423 -1 result.reason = [ result.reason ];27424 -1 result.reason.push(validTokenValue.reason);27425 -1 } else {27426 -1 result.reason = validTokenValue.reason;27427 -1 result.possibleValues = validTokenValue.possibleValues;27428 -1 }27429 -1 }27430 -1 // TODO (more structured result)27431 -1 if (result.values)27432 -1 result.values.push(validTokenValue.value);27433 -1 else27434 -1 result.values = [validTokenValue.value];27435 -1 }27436 -1 return result;27437 -1 case "tristate":27438 -1 var validTristate = axs.utils.isPossibleValue(value.toLowerCase(), axs.constants.MIXED_VALUES, propertyName);27439 -1 if (validTristate.valid) {27440 -1 result.valid = true;27441 -1 result.value = validTristate.value;27442 -1 } else {27443 -1 result.valid = false;27444 -1 result.value = value;27445 -1 result.reason = validTristate.reason;27446 -1 }27447 -1 return result;27448 -1 case "boolean":27449 -1 var validBoolean = axs.utils.isValidBoolean(value);27450 -1 if (validBoolean.valid) {27451 -1 result.valid = true;27452 -1 result.value = validBoolean.value;27453 -1 } else {27454 -1 result.valid = false;27455 -1 result.value = value;27456 -1 result.reason = validBoolean.reason;27457 -1 }27458 -1 return result;27459 -1 }27460 -1 result.valid = false;27461 -1 result.reason = 'Not a valid ARIA property';27462 -1 return result;27463 -1 };27464 -127465 -1 /**27466 -1 * @param {string} propertyName The name of the property.27467 -1 * @param {string} value The value to check.27468 -1 * @return {!Object}27469 -1 */27470 -1 axs.utils.isValidTokenValue = function(propertyName, value) {27471 -1 var propertyKey = propertyName.replace(/^aria-/, '');27472 -1 var propertyDetails = axs.constants.ARIA_PROPERTIES[propertyKey];27473 -1 var possibleValues = propertyDetails.valuesSet;27474 -1 return axs.utils.isPossibleValue(value, possibleValues, propertyName);27475 -1 };27476 -127477 -1 /**27478 -1 * @param {string} value27479 -1 * @param {Object.<string, boolean>} possibleValues27480 -1 * @param {string} propertyName The name of the property.27481 -1 * @return {!Object}27482 -1 */27483 -1 axs.utils.isPossibleValue = function(value, possibleValues, propertyName) {27484 -1 if (!possibleValues[value])27485 -1 return { 'valid': false,27486 -1 'value': value,27487 -1 'reason': '"' + value + '" is not a valid value for ' + propertyName,27488 -1 'possibleValues': Object.keys(possibleValues) };27489 -1 return { 'valid': true, 'value': value };27490 -1 };27491 -127492 -1 /**27493 -1 * @param {string} value27494 -1 * @return {!Object}27495 -1 */27496 -1 axs.utils.isValidBoolean = function(value) {27497 -1 try {27498 -1 var parsedValue = JSON.parse(value);27499 -1 } catch (e) {27500 -1 parsedValue = '';27501 -1 }27502 -1 if (typeof(parsedValue) != 'boolean')27503 -1 return { 'valid': false,27504 -1 'value': value,27505 -1 'reason': '"' + value + '" is not a true/false value' };27506 -1 return { 'valid': true, 'value': parsedValue };27507 -1 };27508 -127509 -1 /**27510 -1 * @param {string} value27511 -1 * @param {!Element} element27512 -1 * @return {!Object}27513 -1 */27514 -1 axs.utils.isValidIDRefValue = function(value, element) {27515 -1 if (value.length == 0)27516 -1 return { 'valid': true, 'idref': value };27517 -1 if (!element.ownerDocument.getElementById(value))27518 -1 return { 'valid': false,27519 -1 'idref': value,27520 -1 'reason': 'No element with ID "' + value + '"' };27521 -1 return { 'valid': true, 'idref': value };27522 -1 };27523 -127524 -1 /**27525 -1 * Tests if a number is real number for a11y purposes.27526 -1 * Must be a real, numerical, decimal value; heavily inspired by27527 -1 * http://www.w3.org/TR/wai-aria/states_and_properties#valuetype_number27528 -1 * @param {string} value27529 -1 * @return {!Object}27530 -1 */27531 -1 axs.utils.isValidNumber = function(value) {27532 -1 var failResult = {27533 -1 'valid': false,27534 -1 'value': value,27535 -1 'reason': '"' + value + '" is not a number'27536 -1 };27537 -1 if (!value) {27538 -1 return failResult;27539 -1 }27540 -1 if (/^0x/i.test(value)) {27541 -1 failResult.reason = '"' + value + '" is not a decimal number'; // hex is not accepted27542 -1 return failResult;27543 -1 }27544 -1 var parsedValue = value * 1;27545 -1 if (!isFinite(parsedValue)) {27546 -1 return failResult;27547 -1 }27548 -1 return { 'valid': true, 'value': parsedValue };27549 -1 };27550 -127551 -1 /**27552 -1 * @param {Element} element27553 -1 * @return {boolean}27554 -1 */27555 -1 axs.utils.isElementImplicitlyFocusable = function(element) {27556 -1 var defaultView = element.ownerDocument.defaultView;27557 -127558 -1 if (element instanceof defaultView.HTMLAnchorElement ||27559 -1 element instanceof defaultView.HTMLAreaElement)27560 -1 return element.hasAttribute('href');27561 -1 if (element instanceof defaultView.HTMLInputElement ||27562 -1 element instanceof defaultView.HTMLSelectElement ||27563 -1 element instanceof defaultView.HTMLTextAreaElement ||27564 -1 element instanceof defaultView.HTMLButtonElement ||27565 -1 element instanceof defaultView.HTMLIFrameElement)27566 -1 return !element.disabled;27567 -1 return false;27568 -1 };27569 -127570 -1 /**27571 -1 * Returns an array containing the values of the given JSON-compatible object.27572 -1 * (Simply ignores any function values.)27573 -1 * @param {Object} obj27574 -1 * @return {Array}27575 -1 */27576 -1 axs.utils.values = function(obj) {27577 -1 var values = [];27578 -1 for (var key in obj) {27579 -1 if (obj.hasOwnProperty(key) && typeof obj[key] != 'function')27580 -1 values.push(obj[key]);27581 -1 }27582 -1 return values;27583 -1 };27584 -127585 -1 /**27586 -1 * Returns an object containing the same keys and values as the given27587 -1 * JSON-compatible object. (Simply ignores any function values.)27588 -1 * @param {Object} obj27589 -1 * @return {Object}27590 -1 */27591 -1 axs.utils.namedValues = function(obj) {27592 -1 var values = {};27593 -1 for (var key in obj) {27594 -1 if (obj.hasOwnProperty(key) && typeof obj[key] != 'function')27595 -1 values[key] = obj[key];27596 -1 }27597 -1 return values;27598 -1 };27599 -127600 -1 /**27601 -1 * Escapes a given ID to be used in a CSS selector27602 -1 *27603 -1 * @private27604 -1 * @param {!string} id The ID to be escaped27605 -1 * @return {string} The escaped ID27606 -1 */27607 -1 function escapeId(id) {27608 -1 return id.replace(/[^a-zA-Z0-9_-]/g,function(match) { return '\\' + match; });27609 -1 }27610 -127611 -1 /** Gets a CSS selector text for a DOM object.27612 -1 * @param {Node} obj The DOM object.27613 -1 * @return {string} CSS selector text for the DOM object.27614 -1 */27615 -1 axs.utils.getQuerySelectorText = function(obj) {27616 -1 if (obj == null || obj.tagName == 'HTML') {27617 -1 return 'html';27618 -1 } else if (obj.tagName == 'BODY') {27619 -1 return 'body';27620 -1 }27621 -127622 -1 if (obj.hasAttribute) {27623 -1 if (obj.id) {27624 -1 return '#' + escapeId(obj.id);27625 -1 }27626 -127627 -1 if (obj.className) {27628 -1 var selector = '';27629 -1 for (var i = 0; i < obj.classList.length; i++)27630 -1 selector += '.' + obj.classList[i];27631 -127632 -1 var total = 0;27633 -1 if (obj.parentNode) {27634 -1 for (i = 0; i < obj.parentNode.children.length; i++) {27635 -1 var similar = obj.parentNode.children[i];27636 -1 if (axs.browserUtils.matchSelector(similar, selector))27637 -1 total++;27638 -1 if (similar === obj)27639 -1 break;27640 -1 }27641 -1 } else {27642 -1 total = 1;27643 -1 }27644 -127645 -1 if (total == 1) {27646 -1 return axs.utils.getQuerySelectorText(obj.parentNode) +27647 -1 ' > ' + selector;27648 -1 }27649 -1 }27650 -127651 -1 if (obj.parentNode) {27652 -1 var similarTags = obj.parentNode.children;27653 -1 var total = 1;27654 -1 var i = 0;27655 -1 while (similarTags[i] !== obj) {27656 -1 if (similarTags[i].tagName == obj.tagName) {27657 -1 total++;27658 -1 }27659 -1 i++;27660 -1 }27661 -127662 -1 var next = '';27663 -1 if (obj.parentNode.tagName != 'BODY') {27664 -1 next = axs.utils.getQuerySelectorText(obj.parentNode) +27665 -1 ' > ';27666 -1 }27667 -127668 -1 if (total == 1) {27669 -1 return next +27670 -1 obj.tagName;27671 -1 } else {27672 -1 return next +27673 -1 obj.tagName +27674 -1 ':nth-of-type(' + total + ')';27675 -1 }27676 -1 }27677 -127678 -1 } else if (obj.selectorText) {27679 -1 return obj.selectorText;27680 -1 }27681 -127682 -1 return '';27683 -1 };27684 -127685 -1 /**27686 -1 * Gets elements that refer to this element in an ARIA attribute that takes an ID reference list or27687 -1 * single ID reference.27688 -1 * @param {Element} element a potential referent.27689 -1 * @param {string=} opt_attributeName Name of an ARIA attribute to limit the results to, e.g. 'aria-owns'.27690 -1 * @return {NodeList} The elements that refer to this element or null.27691 -1 */27692 -1 axs.utils.getAriaIdReferrers = function(element, opt_attributeName) {27693 -1 var propertyToSelector = function(propertyKey) {27694 -1 var propertyDetails = axs.constants.ARIA_PROPERTIES[propertyKey];27695 -1 if (propertyDetails) {27696 -1 if (propertyDetails.valueType === ('idref')) {27697 -1 return '[aria-' + propertyKey + '=\'' + id + '\']';27698 -1 } else if (propertyDetails.valueType === ('idref_list')) {27699 -1 return '[aria-' + propertyKey + '~=\'' + id + '\']';27700 -1 }27701 -1 }27702 -1 return '';27703 -1 };27704 -1 if (!element)27705 -1 return null;27706 -1 var id = element.id;27707 -1 if (!id)27708 -1 return null;27709 -1 id = id.replace(/'/g, "\\'"); // make it safe to use in a selector27710 -127711 -1 if (opt_attributeName) {27712 -1 var propertyKey = opt_attributeName.replace(/^aria-/, '');27713 -1 var referrerQuery = propertyToSelector(propertyKey);27714 -1 if (referrerQuery) {27715 -1 return element.ownerDocument.querySelectorAll(referrerQuery);27716 -1 }27717 -1 } else {27718 -1 var selectors = [];27719 -1 for (var propertyKey in axs.constants.ARIA_PROPERTIES) {27720 -1 var referrerQuery = propertyToSelector(propertyKey);27721 -1 if (referrerQuery) {27722 -1 selectors.push(referrerQuery);27723 -1 }27724 -1 }27725 -1 return element.ownerDocument.querySelectorAll(selectors.join(','));27726 -1 }27727 -1 return null;27728 -1 };27729 -127730 -1 /**27731 -1 * Gets elements that refer to this element in an HTML attribute that takes an ID reference list or27732 -1 * single ID reference.27733 -1 * @param {Element} element a potential referent.27734 -1 * @return {NodeList} The elements that refer to this element.27735 -1 */27736 -1 axs.utils.getHtmlIdReferrers = function(element) {27737 -1 if (!element)27738 -1 return null;27739 -1 var id = element.id;27740 -1 if (!id)27741 -1 return null;27742 -1 id = id.replace(/'/g, "\\'"); // make it safe to use in a selector27743 -1 var selectorTemplates = [27744 -1 '[contextmenu=\'{id}\']',27745 -1 '[itemref~=\'{id}\']',27746 -1 'button[form=\'{id}\']',27747 -1 'button[menu=\'{id}\']',27748 -1 'fieldset[form=\'{id}\']',27749 -1 'input[form=\'{id}\']',27750 -1 'input[list=\'{id}\']',27751 -1 'keygen[form=\'{id}\']',27752 -1 'label[for=\'{id}\']',27753 -1 'label[form=\'{id}\']',27754 -1 'menuitem[command=\'{id}\']',27755 -1 'object[form=\'{id}\']',27756 -1 'output[for~=\'{id}\']',27757 -1 'output[form=\'{id}\']',27758 -1 'select[form=\'{id}\']',27759 -1 'td[headers~=\'{id}\']',27760 -1 'textarea[form=\'{id}\']',27761 -1 'tr[headers~=\'{id}\']'];27762 -1 var selectors = selectorTemplates.map(function(selector) {27763 -1 return selector.replace('\{id\}', id);27764 -1 });27765 -1 return element.ownerDocument.querySelectorAll(selectors.join(','));27766 -1 };27767 -127768 -1 /**27769 -1 * Gets a list of all IDs this element references in either ARIA or HTML attributes.27770 -1 *27771 -1 * @param {Element} element The element to check for idref attributes.27772 -1 * @returns {Array.<string>} Any IDs this element references.27773 -1 */27774 -1 axs.utils.getReferencedIds = function(element) {27775 -1 var result = [];27776 -1 var addResult = function(ids) {27777 -1 if (ids) {27778 -1 if (ids.indexOf(' ') > 0) {27779 -1 result = result.concat(attrib.value.split(' '));27780 -1 } else {27781 -1 result.push(ids);27782 -1 }27783 -1 }27784 -1 };27785 -1 for (var i = 0; i < element.attributes.length; i++) {27786 -1 var tagName = element.tagName.toLowerCase();27787 -1 var attrib = element.attributes[i];27788 -1 if (attrib.specified) {27789 -1 var attribName = attrib.name;27790 -1 var ariaAttr = attribName.match(/aria-(.+)/);27791 -1 if (ariaAttr) {27792 -1 var details = axs.constants.ARIA_PROPERTIES[ariaAttr[1]];27793 -1 if (details && (details.valueType === ('idref') || details.valueType === ('idref_list'))) {27794 -1 addResult(attrib.value);27795 -1 }27796 -1 continue;27797 -1 }27798 -1 switch (attribName) {27799 -1 case 'contextmenu':27800 -1 case 'itemref':27801 -1 addResult(attrib.value);27802 -1 break;27803 -1 case 'form':27804 -1 if (tagName == 'button' || tagName == 'fieldset' || tagName == 'input' ||27805 -1 tagName == 'keygen' || tagName == 'label' || tagName == 'object' ||27806 -1 tagName == 'output' || tagName == 'select' || tagName == 'textarea') {27807 -1 addResult(attrib.value);27808 -1 }27809 -1 break;27810 -1 case 'for':27811 -1 if (tagName == 'label' || tagName == 'output') {27812 -1 addResult(attrib.value);27813 -1 }27814 -1 break;27815 -1 case 'menu':27816 -1 if (tagName == 'button') {27817 -1 addResult(attrib.value);27818 -1 }27819 -1 break;27820 -1 case 'list':27821 -1 if (tagName == 'input') {27822 -1 addResult(attrib.value);27823 -1 }27824 -1 break;27825 -1 case 'command':27826 -1 if (tagName == 'menuitem') {27827 -1 addResult(attrib.value);27828 -1 }27829 -1 break;27830 -1 case 'headers':27831 -1 if (tagName == 'td' || tagName == 'tr') {27832 -1 addResult(attrib.value);27833 -1 }27834 -1 break;27835 -1 }27836 -1 }27837 -1 }27838 -1 return result;27839 -1 };27840 -127841 -1 /**27842 -1 * Gets elements that refer to this element in an attribute that takes an ID reference list or27843 -1 * single ID reference.27844 -1 * @param {Element} element a potential referent.27845 -1 * @return {Array<Element>} The elements that refer to this element.27846 -1 */27847 -1 axs.utils.getIdReferrers = function(element) {27848 -1 var result = [];27849 -1 var referrers = axs.utils.getHtmlIdReferrers(element);27850 -1 if (referrers) {27851 -1 result = result.concat(Array.prototype.slice.call(referrers));27852 -1 }27853 -1 referrers = axs.utils.getAriaIdReferrers(element);27854 -1 if (referrers) {27855 -1 result = result.concat(Array.prototype.slice.call(referrers));27856 -1 }27857 -1 return result;27858 -1 };27859 -127860 -1 /**27861 -1 * Gets elements which this element refers to in the given attribute.27862 -1 * @param {!string} attributeName Name of an ARIA attribute, e.g. 'aria-owns'.27863 -1 * @param {Element} element The DOM element which has the ARIA attribute.27864 -1 * @return {!Array.<Element>} An array of elements that are referred to by this element.27865 -1 * @example27866 -1 * var owner = document.body.appendChild(document.createElement("div"));27867 -1 * var owned = document.body.appendChild(document.createElement("div"));27868 -1 * owner.setAttribute("aria-owns", "kungfu");27869 -1 * owned.setAttribute("id", "kungfu");27870 -1 * console.log(axs.utils.getIdReferents("aria-owns", owner)[0] === owned); // This will log 'true'27871 -1 */27872 -1 axs.utils.getIdReferents = function(attributeName, element) {27873 -1 var result = [];27874 -1 var propertyKey = attributeName.replace(/^aria-/, '');27875 -1 var property = axs.constants.ARIA_PROPERTIES[propertyKey];27876 -1 if (!property || !element.hasAttribute(attributeName))27877 -1 return result;27878 -1 var propertyType = property.valueType;27879 -1 if (propertyType === 'idref_list' || propertyType === 'idref') {27880 -1 var ownerDocument = element.ownerDocument;27881 -1 var ids = element.getAttribute(attributeName);27882 -1 ids = ids.split(/\s+/);27883 -1 for (var i = 0, len = ids.length; i < len; i++) {27884 -1 var next = ownerDocument.getElementById(ids[i]);27885 -1 if (next) {27886 -1 result[result.length] = next;27887 -1 }27888 -1 }27889 -1 }27890 -1 return result;27891 -1 };27892 -127893 -1 /**27894 -1 * Gets a subset of 'axs.constants.ARIA_PROPERTIES' filtered by 'valueType'.27895 -1 * @param {!Array.<string>} valueTypes Types to match, e.g. ['idref_list'].27896 -1 * @return {Object.<string, Object>} axs.constants.ARIA_PROPERTIES which match.27897 -1 */27898 -1 axs.utils.getAriaPropertiesByValueType = function(valueTypes) {27899 -1 var result = {};27900 -1 for (var propertyName in axs.constants.ARIA_PROPERTIES) {27901 -1 var property = axs.constants.ARIA_PROPERTIES[propertyName];27902 -1 if (property && valueTypes.indexOf(property.valueType) >= 0) {27903 -1 result[propertyName] = property;27904 -1 }27905 -1 }27906 -1 return result;27907 -1 };27908 -127909 -1 /**27910 -1 * Builds a selector that matches an element with any of these ARIA properties.27911 -1 * @param {Object.<string, Object>} ariaProperties axs.constants.ARIA_PROPERTIES27912 -1 * @return {!string} The selector.27913 -1 */27914 -1 axs.utils.getSelectorForAriaProperties = function(ariaProperties) {27915 -1 var propertyNames = Object.keys(/** @type {!Object} */(ariaProperties));27916 -1 var result = propertyNames.map(function(propertyName) {27917 -1 return '[aria-' + propertyName + ']';27918 -1 });27919 -1 result.sort(); // facilitates reading long selectors and unit testing27920 -1 return result.join(',');27921 -1 };27922 -127923 -1 /**27924 -1 * Finds descendants of this element which implement the given ARIA role.27925 -1 * Will look for descendants with implicit or explicit role.27926 -1 * @param {Element} element an HTML DOM element.27927 -1 * @param {string} role The role you seek.27928 -1 * @return {!Array.<Element>} An array of matching elements.27929 -1 * @example27930 -1 * var container = document.createElement("div");27931 -1 * var button = document.createElement("button");27932 -1 * var span = document.createElement("span");27933 -1 * span.setAttribute("role", "button");27934 -1 * container.appendChild(button);27935 -1 * container.appendChild(span);27936 -1 * var result = axs.utils.findDescendantsWithRole(container, "button"); // result is an array containing both 'button' and 'span'27937 -1 */27938 -1 axs.utils.findDescendantsWithRole = function(element, role) {27939 -1 if (!(element && role))27940 -1 return [];27941 -1 var selector = axs.properties.getSelectorForRole(role);27942 -1 if (!selector)27943 -1 return [];27944 -1 var result = element.querySelectorAll(selector);27945 -1 if (result) { // Convert NodeList to Array; methinks 80/20 that's what callers want.27946 -1 result = Array.prototype.map.call(result, function(item) { return item; });27947 -1 } else {27948 -1 return [];27949 -1 }27950 -1 return result;27951 -1 };27952 -127953 -1 },{}],189:[function(require,module,exports){27954 -1 // Copyright 2013 Google Inc.27955 -1 //27956 -1 // Licensed under the Apache License, Version 2.0 (the "License");27957 -1 // you may not use this file except in compliance with the License.27958 -1 // You may obtain a copy of the License at27959 -1 //27960 -1 // http://www.apache.org/licenses/LICENSE-2.027961 -1 //27962 -1 // Unless required by applicable law or agreed to in writing, software27963 -1 // distributed under the License is distributed on an "AS IS" BASIS,27964 -1 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.27965 -1 // See the License for the specific language governing permissions and27966 -1 // limitations under the License.27967 -127968 -1 goog.provide('axs.browserUtils');27969 -127970 -1 /**27971 -1 * Use Webkit matcher when matches() is not supported.27972 -1 * Use Firefox matcher when Webkit is not supported.27973 -1 * Use IE matcher when neither webkit nor Firefox supported.27974 -1 * @param {Element} element27975 -1 * @param {string} selector27976 -1 * @return {boolean} true if the element matches the selector27977 -1 */27978 -1 axs.browserUtils.matchSelector = function(element, selector) {27979 -1 if (element.matches)27980 -1 return element.matches(selector);27981 -1 if (element.webkitMatchesSelector)27982 -1 return element.webkitMatchesSelector(selector);27983 -1 if (element.mozMatchesSelector)27984 -1 return element.mozMatchesSelector(selector);27985 -1 if (element.msMatchesSelector)27986 -1 return element.msMatchesSelector(selector);27987 -1 return false;27988 -1 };27989 -127990 -1 },{}],190:[function(require,module,exports){27991 -1 // Copyright 2015 Google Inc.27992 -1 //27993 -1 // Licensed under the Apache License, Version 2.0 (the "License");27994 -1 // you may not use this file except in compliance with the License.27995 -1 // You may obtain a copy of the License at27996 -1 //27997 -1 // http://www.apache.org/licenses/LICENSE-2.027998 -1 //27999 -1 // Unless required by applicable law or agreed to in writing, software28000 -1 // distributed under the License is distributed on an "AS IS" BASIS,28001 -1 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.28002 -1 // See the License for the specific language governing permissions and28003 -1 // limitations under the License.28004 -128005 -1 goog.provide('axs.color');28006 -1 goog.provide('axs.color.Color');28007 -128008 -1 /**28009 -1 * @constructor28010 -1 * @param {number} red28011 -1 * @param {number} green28012 -1 * @param {number} blue28013 -1 * @param {number} alpha28014 -1 */28015 -1 axs.color.Color = function(red, green, blue, alpha) {28016 -1 /** @type {number} */28017 -1 this.red = red;28018 -128019 -1 /** @type {number} */28020 -1 this.green = green;28021 -128022 -1 /** @type {number} */28023 -1 this.blue = blue;28024 -128025 -1 /** @type {number} */28026 -1 this.alpha = alpha;28027 -1 };28028 -128029 -1 /**28030 -1 * @constructor28031 -1 * See https://en.wikipedia.org/wiki/YCbCr for more information.28032 -1 * @param {Array.<number>} coords The YCbCr values as a 3 element array, in the order [luma, Cb, Cr].28033 -1 * All numbers are in the range [0, 1].28034 -1 */28035 -1 axs.color.YCbCr = function(coords) {28036 -1 /** @type {number} */28037 -1 this.luma = this.z = coords[0];28038 -128039 -1 /** @type {number} */28040 -1 this.Cb = this.x = coords[1];28041 -128042 -1 /** @type {number} */28043 -1 this.Cr = this.y = coords[2];28044 -1 };28045 -128046 -1 axs.color.YCbCr.prototype = {28047 -1 /**28048 -1 * @param {number} scalar28049 -1 * @return {axs.color.YCbCr} This color multiplied by the given scalar28050 -1 */28051 -1 multiply: function(scalar) {28052 -1 var result = [ this.luma * scalar, this.Cb * scalar, this.Cr * scalar ];28053 -1 return new axs.color.YCbCr(result);28054 -1 },28055 -128056 -1 /**28057 -1 * @param {axs.color.YCbCr} other28058 -1 * @return {axs.color.YCbCr} This plus other28059 -1 */28060 -1 add: function(other) {28061 -1 var result = [ this.luma + other.luma, this.Cb + other.Cb, this.Cr + other.Cr ];28062 -1 return new axs.color.YCbCr(result);28063 -1 },28064 -128065 -1 /**28066 -1 * @param {axs.color.YCbCr} other28067 -1 * @return {axs.color.YCbCr} This minus other28068 -1 */28069 -1 subtract: function(other) {28070 -1 var result = [ this.luma - other.luma, this.Cb - other.Cb, this.Cr - other.Cr ];28071 -1 return new axs.color.YCbCr(result);28072 -1 }28073 -128074 -1 };28075 -128076 -128077 -1 /**28078 -1 * Calculate the contrast ratio between the two given colors. Returns the ratio28079 -1 * to 1, for example for two two colors with a contrast ratio of 21:1, this28080 -1 * function will return 21.28081 -1 * @param {axs.color.Color} fgColor28082 -1 * @param {axs.color.Color} bgColor28083 -1 * @return {!number}28084 -1 */28085 -1 axs.color.calculateContrastRatio = function(fgColor, bgColor) {28086 -1 if (fgColor.alpha < 1)28087 -1 fgColor = axs.color.flattenColors(fgColor, bgColor);28088 -128089 -1 var fgLuminance = axs.color.calculateLuminance(fgColor);28090 -1 var bgLuminance = axs.color.calculateLuminance(bgColor);28091 -1 var contrastRatio = (Math.max(fgLuminance, bgLuminance) + 0.05) /28092 -1 (Math.min(fgLuminance, bgLuminance) + 0.05);28093 -1 return contrastRatio;28094 -1 };28095 -128096 -1 /**28097 -1 * Calculate the luminance of the given color using the WCAG algorithm.28098 -1 * @param {axs.color.Color} color28099 -1 * @return {number}28100 -1 */28101 -1 axs.color.calculateLuminance = function(color) {28102 -1 /* var rSRGB = color.red / 255;28103 -1 var gSRGB = color.green / 255;28104 -1 var bSRGB = color.blue / 255;28105 -128106 -1 var r = rSRGB <= 0.03928 ? rSRGB / 12.92 : Math.pow(((rSRGB + 0.055)/1.055), 2.4);28107 -1 var g = gSRGB <= 0.03928 ? gSRGB / 12.92 : Math.pow(((gSRGB + 0.055)/1.055), 2.4);28108 -1 var b = bSRGB <= 0.03928 ? bSRGB / 12.92 : Math.pow(((bSRGB + 0.055)/1.055), 2.4);28109 -128110 -1 return 0.2126 * r + 0.7152 * g + 0.0722 * b; */28111 -1 var ycc = axs.color.toYCbCr(color);28112 -1 return ycc.luma;28113 -1 };28114 -128115 -1 /**28116 -1 * Compute the luminance ratio between two luminance values.28117 -1 * @param {number} luminance128118 -1 * @param {number} luminance228119 -1 */28120 -1 axs.color.luminanceRatio = function(luminance1, luminance2) {28121 -1 return (Math.max(luminance1, luminance2) + 0.05) /28122 -1 (Math.min(luminance1, luminance2) + 0.05);28123 -1 };28124 -128125 -1 /**28126 -1 * @param {string} colorString The color string from CSS.28127 -1 * @return {?axs.color.Color}28128 -1 */28129 -1 axs.color.parseColor = function(colorString) {28130 -1 if (colorString === "transparent") {28131 -1 return new axs.color.Color(0, 0, 0, 0);28132 -1 }28133 -1 var rgbRegex = /^rgb\((\d+), (\d+), (\d+)\)$/;28134 -1 var match = colorString.match(rgbRegex);28135 -128136 -1 if (match) {28137 -1 var r = parseInt(match[1], 10);28138 -1 var g = parseInt(match[2], 10);28139 -1 var b = parseInt(match[3], 10);28140 -1 var a = 1;28141 -1 return new axs.color.Color(r, g, b, a);28142 -1 }28143 -128144 -1 var rgbaRegex = /^rgba\((\d+), (\d+), (\d+), (\d*(\.\d+)?)\)/;28145 -1 match = colorString.match(rgbaRegex);28146 -1 if (match) {28147 -1 var r = parseInt(match[1], 10);28148 -1 var g = parseInt(match[2], 10);28149 -1 var b = parseInt(match[3], 10);28150 -1 var a = parseFloat(match[4]);28151 -1 return new axs.color.Color(r, g, b, a);28152 -1 }28153 -128154 -1 return null;28155 -1 };28156 -128157 -1 /**28158 -1 * @param {number} value The value of a color channel, 0 <= value <= 0xFF28159 -1 * @return {!string}28160 -1 */28161 -1 axs.color.colorChannelToString = function(value) {28162 -1 value = Math.round(value);28163 -1 if (value <= 0xF)28164 -1 return '0' + value.toString(16);28165 -1 return value.toString(16);28166 -1 };28167 -128168 -1 /**28169 -1 * @param {axs.color.Color} color28170 -1 * @return {!string}28171 -1 */28172 -1 axs.color.colorToString = function(color) {28173 -1 if (color.alpha == 1) {28174 -1 return '#' + axs.color.colorChannelToString(color.red) +28175 -1 axs.color.colorChannelToString(color.green) + axs.color.colorChannelToString(color.blue);28176 -1 }28177 -1 else28178 -1 return 'rgba(' + [color.red, color.green, color.blue, color.alpha].join(',') + ')';28179 -1 };28180 -128181 -1 /**28182 -1 * Compute a desired luminance given a given luminance and a desired contrast ratio.28183 -1 * @param {number} luminance The given luminance.28184 -1 * @param {number} contrast The desired contrast ratio.28185 -1 * @param {boolean} higher Whether the desired luminance is higher or lower than the given luminance.28186 -1 * @return {number} The desired luminance.28187 -1 */28188 -1 axs.color.luminanceFromContrastRatio = function(luminance, contrast, higher) {28189 -1 if (higher) {28190 -1 var newLuminance = (luminance + 0.05) * contrast - 0.05;28191 -1 return newLuminance;28192 -1 } else {28193 -1 var newLuminance = (luminance + 0.05) / contrast - 0.05;28194 -1 return newLuminance;28195 -1 }28196 -1 };28197 -128198 -1 /**28199 -1 * Given a color in YCbCr format and a desired luminance, pick a new color with the desired luminance which is28200 -1 * as close as possible to the original color.28201 -1 * @param {axs.color.YCbCr} ycc The original color in YCbCr form.28202 -1 * @param {number} luma The desired luminance28203 -1 * @return {!axs.color.Color} A new color in RGB.28204 -1 */28205 -1 axs.color.translateColor = function(ycc, luma) {28206 -1 var endpoint = (luma > ycc.luma) ? axs.color.WHITE_YCC : axs.color.BLACK_YCC;28207 -1 var cubeFaces = (endpoint == axs.color.WHITE_YCC) ? axs.color.YCC_CUBE_FACES_WHITE28208 -1 : axs.color.YCC_CUBE_FACES_BLACK;28209 -128210 -1 var a = new axs.color.YCbCr([0, ycc.Cb, ycc.Cr]);28211 -1 var b = new axs.color.YCbCr([1, ycc.Cb, ycc.Cr]);28212 -1 var line = { a: a, b: b };28213 -128214 -1 var intersection = null;28215 -1 for (var i = 0; i < cubeFaces.length; i++) {28216 -1 var cubeFace = cubeFaces[i];28217 -1 intersection = axs.color.findIntersection(line, cubeFace);28218 -1 // If intersection within [0, 1] in Z axis, it is within the cube.28219 -1 if (intersection.z >= 0 && intersection.z <= 1)28220 -1 break;28221 -1 }28222 -1 if (!intersection) {28223 -1 // Should never happen28224 -1 throw "Couldn't find intersection with YCbCr color cube for Cb=" + ycc.Cb + ", Cr=" + ycc.Cr + ".";28225 -1 }28226 -1 if (intersection.x != ycc.x || intersection.y != ycc.y) {28227 -1 // Should never happen28228 -1 throw "Intersection has wrong Cb/Cr values.";28229 -1 }28230 -128231 -1 // If intersection.luma is closer to endpoint than desired luma, then luma is inside cube28232 -1 // and we can immediately return new value.28233 -1 if (Math.abs(endpoint.luma - intersection.luma) < Math.abs(endpoint.luma - luma)) {28234 -1 var translatedColor = [luma, ycc.Cb, ycc.Cr];28235 -1 return axs.color.fromYCbCrArray(translatedColor);28236 -1 }28237 -128238 -1 // Otherwise, translate from intersection towards white/black such that luma is correct.28239 -1 var dLuma = luma - intersection.luma;28240 -1 var scale = dLuma / (endpoint.luma - intersection.luma);28241 -1 var translatedColor = [ luma,28242 -1 intersection.Cb - (intersection.Cb * scale),28243 -1 intersection.Cr - (intersection.Cr * scale) ];28244 -128245 -1 return axs.color.fromYCbCrArray(translatedColor);28246 -1 };28247 -128248 -1 /** @typedef {{fg: string, bg: string, contrast: string}} */28249 -1 axs.color.SuggestedColors;28250 -128251 -1 /**28252 -1 * @param {axs.color.Color} bgColor28253 -1 * @param {axs.color.Color} fgColor28254 -1 * @param {Object.<string, number>} desiredContrastRatios A map of label to desired contrast ratio.28255 -1 * @return {Object.<string, axs.color.SuggestedColors>}28256 -1 */28257 -1 axs.color.suggestColors = function(bgColor, fgColor, desiredContrastRatios) {28258 -1 var colors = {};28259 -1 var bgLuminance = axs.color.calculateLuminance(bgColor);28260 -1 var fgLuminance = axs.color.calculateLuminance(fgColor);28261 -128262 -1 var fgLuminanceIsHigher = fgLuminance > bgLuminance;28263 -1 var fgYCbCr = axs.color.toYCbCr(fgColor);28264 -1 var bgYCbCr = axs.color.toYCbCr(bgColor);28265 -1 for (var desiredLabel in desiredContrastRatios) {28266 -1 var desiredContrast = desiredContrastRatios[desiredLabel];28267 -128268 -1 var desiredFgLuminance = axs.color.luminanceFromContrastRatio(bgLuminance, desiredContrast + 0.02, fgLuminanceIsHigher);28269 -1 if (desiredFgLuminance <= 1 && desiredFgLuminance >= 0) {28270 -1 var newFgColor = axs.color.translateColor(fgYCbCr, desiredFgLuminance);28271 -1 var newContrastRatio = axs.color.calculateContrastRatio(newFgColor, bgColor);28272 -1 var suggestedColors = {};28273 -1 suggestedColors.fg = /** @type {!string} */ (axs.color.colorToString(newFgColor));28274 -1 suggestedColors.bg = /** @type {!string} */ (axs.color.colorToString(bgColor));28275 -1 suggestedColors.contrast = /** @type {!string} */ (newContrastRatio.toFixed(2));28276 -1 colors[desiredLabel] = /** @type {axs.color.SuggestedColors} */ (suggestedColors);28277 -1 continue;28278 -1 }28279 -128280 -1 var desiredBgLuminance = axs.color.luminanceFromContrastRatio(fgLuminance, desiredContrast + 0.02, !fgLuminanceIsHigher);28281 -1 if (desiredBgLuminance <= 1 && desiredBgLuminance >= 0) {28282 -1 var newBgColor = axs.color.translateColor(bgYCbCr, desiredBgLuminance);28283 -1 var newContrastRatio = axs.color.calculateContrastRatio(fgColor, newBgColor);28284 -1 var suggestedColors = {};28285 -1 suggestedColors.bg = /** @type {!string} */ (axs.color.colorToString(newBgColor));28286 -1 suggestedColors.fg = /** @type {!string} */ (axs.color.colorToString(fgColor));28287 -1 suggestedColors.contrast = /** @type {!string} */ (newContrastRatio.toFixed(2));28288 -1 colors[desiredLabel] = /** @type {axs.color.SuggestedColors} */ (suggestedColors);28289 -1 }28290 -1 }28291 -1 return colors;28292 -1 };28293 -128294 -1 /**28295 -1 * Combine the two given color according to alpha blending.28296 -1 * @param {axs.color.Color} fgColor28297 -1 * @param {axs.color.Color} bgColor28298 -1 * @return {axs.color.Color}28299 -1 */28300 -1 axs.color.flattenColors = function(fgColor, bgColor) {28301 -1 var alpha = fgColor.alpha;28302 -1 var r = ((1 - alpha) * bgColor.red) + (alpha * fgColor.red);28303 -1 var g = ((1 - alpha) * bgColor.green) + (alpha * fgColor.green);28304 -1 var b = ((1 - alpha) * bgColor.blue) + (alpha * fgColor.blue);28305 -1 var a = fgColor.alpha + (bgColor.alpha * (1 - fgColor.alpha));28306 -128307 -1 return new axs.color.Color(r, g, b, a);28308 -1 };28309 -128310 -1 /**28311 -1 * Multiply the given vector by the given matrix.28312 -1 * @param {Array.<Array.<number>>} matrix A 3x3 matrix28313 -1 * @param {Array.<number>} vector A 3-element vector28314 -1 * @return {Array.<number>} A 3-element vector28315 -1 */28316 -1 axs.color.multiplyMatrixVector = function(matrix, vector) {28317 -1 var a = matrix[0][0];28318 -1 var b = matrix[0][1];28319 -1 var c = matrix[0][2];28320 -1 var d = matrix[1][0];28321 -1 var e = matrix[1][1];28322 -1 var f = matrix[1][2];28323 -1 var g = matrix[2][0];28324 -1 var h = matrix[2][1];28325 -1 var k = matrix[2][2];28326 -128327 -1 var x = vector[0];28328 -1 var y = vector[1];28329 -1 var z = vector[2];28330 -128331 -1 return [28332 -1 a*x + b*y + c*z,28333 -1 d*x + e*y + f*z,28334 -1 g*x + h*y + k*z28335 -1 ];28336 -1 };28337 -128338 -1 /**28339 -1 * Convert a given RGB color to YCbCr.28340 -1 * @param {axs.color.Color} color28341 -1 * @return {axs.color.YCbCr}28342 -1 */28343 -1 axs.color.toYCbCr = function(color) {28344 -1 var rSRGB = color.red / 255;28345 -1 var gSRGB = color.green / 255;28346 -1 var bSRGB = color.blue / 255;28347 -128348 -1 var r = rSRGB <= 0.03928 ? rSRGB / 12.92 : Math.pow(((rSRGB + 0.055)/1.055), 2.4);28349 -1 var g = gSRGB <= 0.03928 ? gSRGB / 12.92 : Math.pow(((gSRGB + 0.055)/1.055), 2.4);28350 -1 var b = bSRGB <= 0.03928 ? bSRGB / 12.92 : Math.pow(((bSRGB + 0.055)/1.055), 2.4);28351 -128352 -1 return new axs.color.YCbCr(axs.color.multiplyMatrixVector(axs.color.YCC_MATRIX, [r, g, b]));28353 -1 };28354 -128355 -1 /**28356 -1 * @param {axs.color.YCbCr} ycc28357 -1 * @return {!axs.color.Color}28358 -1 */28359 -1 axs.color.fromYCbCr = function(ycc) {28360 -1 return axs.color.fromYCbCrArray([ycc.luma, ycc.Cb, ycc.Cr]);28361 -1 };28362 -128363 -1 /**28364 -1 * Convert a color from a YCbCr color (as a vector) to an RGB color28365 -1 * @param {Array.<number>} yccArray28366 -1 * @return {!axs.color.Color}28367 -1 */28368 -1 axs.color.fromYCbCrArray = function(yccArray) {28369 -1 var rgb = axs.color.multiplyMatrixVector(axs.color.INVERTED_YCC_MATRIX, yccArray);28370 -128371 -1 var r = rgb[0];28372 -1 var g = rgb[1];28373 -1 var b = rgb[2];28374 -1 var rSRGB = r <= 0.00303949 ? (r * 12.92) : (Math.pow(r, (1/2.4)) * 1.055) - 0.055;28375 -1 var gSRGB = g <= 0.00303949 ? (g * 12.92) : (Math.pow(g, (1/2.4)) * 1.055) - 0.055;28376 -1 var bSRGB = b <= 0.00303949 ? (b * 12.92) : (Math.pow(b, (1/2.4)) * 1.055) - 0.055;28377 -128378 -1 var red = Math.min(Math.max(Math.round(rSRGB * 255), 0), 255);28379 -1 var green = Math.min(Math.max(Math.round(gSRGB * 255), 0), 255);28380 -1 var blue = Math.min(Math.max(Math.round(bSRGB * 255), 0), 255);28381 -128382 -1 return new axs.color.Color(red, green, blue, 1);28383 -1 };28384 -128385 -1 /**28386 -1 * Returns an RGB to YCbCr conversion matrix for the given kR, kB constants.28387 -1 * @param {number} kR28388 -1 * @param {number} kB28389 -1 * @return {Array.<Array.<number>>}28390 -1 */28391 -1 axs.color.RGBToYCbCrMatrix = function(kR, kB) {28392 -1 return [28393 -1 [28394 -1 kR,28395 -1 (1 - kR - kB),28396 -1 kB28397 -1 ],28398 -1 [28399 -1 -kR/(2 - 2*kB),28400 -1 (kR + kB - 1)/(2 - 2*kB),28401 -1 (1 - kB)/(2 - 2*kB)28402 -1 ],28403 -1 [28404 -1 (1 - kR)/(2 - 2*kR),28405 -1 (kR + kB - 1)/(2 - 2*kR),28406 -1 -kB/(2 - 2*kR)28407 -1 ]28408 -1 ];28409 -1 };28410 -128411 -1 /**28412 -1 * Return the inverse of the given 3x3 matrix.28413 -1 * @param {Array.<Array.<number>>} matrix28414 -1 * @return Array.<Array.<number>> The inverse of the given matrix.28415 -1 */28416 -1 axs.color.invert3x3Matrix = function(matrix) {28417 -1 var a = matrix[0][0];28418 -1 var b = matrix[0][1];28419 -1 var c = matrix[0][2];28420 -1 var d = matrix[1][0];28421 -1 var e = matrix[1][1];28422 -1 var f = matrix[1][2];28423 -1 var g = matrix[2][0];28424 -1 var h = matrix[2][1];28425 -1 var k = matrix[2][2];28426 -128427 -1 var A = (e*k - f*h);28428 -1 var B = (f*g - d*k);28429 -1 var C = (d*h - e*g);28430 -1 var D = (c*h - b*k);28431 -1 var E = (a*k - c*g);28432 -1 var F = (g*b - a*h);28433 -1 var G = (b*f - c*e);28434 -1 var H = (c*d - a*f);28435 -1 var K = (a*e - b*d);28436 -128437 -1 var det = a * (e*k - f*h) - b * (k*d - f*g) + c * (d*h - e*g);28438 -1 var z = 1/det;28439 -128440 -1 return axs.color.scalarMultiplyMatrix([28441 -1 [ A, D, G ],28442 -1 [ B, E, H ],28443 -1 [ C, F, K ]28444 -1 ], z);28445 -1 };28446 -128447 -1 /** @typedef {{ a: axs.color.YCbCr, b: axs.color.YCbCr }} */28448 -1 axs.color.Line;28449 -128450 -1 /** @typedef {{ p0: axs.color.YCbCr, p1: axs.color.YCbCr, p2: axs.color.YCbCr }} */28451 -1 axs.color.Plane;28452 -128453 -1 /**28454 -1 * Find the intersection between a line and a plane using28455 -1 * http://en.wikipedia.org/wiki/Line%E2%80%93plane_intersection#Parametric_form28456 -1 * @param {axs.color.Line} l28457 -1 * @param {axs.color.Plane} p28458 -1 * @return {axs.color.YCbCr}28459 -1 */28460 -1 axs.color.findIntersection = function(l, p) {28461 -1 var lhs = [ l.a.x - p.p0.x, l.a.y - p.p0.y, l.a.z - p.p0.z ];28462 -128463 -1 var matrix = [ [ l.a.x - l.b.x, p.p1.x - p.p0.x, p.p2.x - p.p0.x ],28464 -1 [ l.a.y - l.b.y, p.p1.y - p.p0.y, p.p2.y - p.p0.y ],28465 -1 [ l.a.z - l.b.z, p.p1.z - p.p0.z, p.p2.z - p.p0.z ] ];28466 -1 var invertedMatrix = axs.color.invert3x3Matrix(matrix);28467 -128468 -1 var tuv = axs.color.multiplyMatrixVector(invertedMatrix, lhs);28469 -1 var t = tuv[0];28470 -128471 -1 var result = l.a.add(l.b.subtract(l.a).multiply(t));28472 -1 return result;28473 -1 };28474 -128475 -1 /**28476 -1 * Multiply a matrix by a scalar.28477 -1 * @param {Array.<Array.<number>>} matrix A 3x3 matrix.28478 -1 * @param {number} scalar28479 -1 * @return {Array.<Array.<number>>}28480 -1 */28481 -1 axs.color.scalarMultiplyMatrix = function(matrix, scalar) {28482 -1 var result = [];28483 -128484 -1 for (var i = 0; i < 3; i++)28485 -1 result[i] = axs.color.scalarMultiplyVector(matrix[i], scalar);28486 -128487 -1 return result;28488 -1 };28489 -128490 -1 /**28491 -1 * Multiply a vector by a scalar.28492 -1 * @param {Array.<number>} vector28493 -1 * @param {number} scalar28494 -1 * @return {Array.<number>} vector28495 -1 */28496 -1 axs.color.scalarMultiplyVector = function(vector, scalar) {28497 -1 var result = [];28498 -1 for (var i = 0; i < vector.length; i++)28499 -1 result[i] = vector[i] * scalar;28500 -1 return result;28501 -1 };28502 -128503 -1 axs.color.kR = 0.2126;28504 -1 axs.color.kB = 0.0722;28505 -1 axs.color.YCC_MATRIX = axs.color.RGBToYCbCrMatrix(axs.color.kR, axs.color.kB);28506 -1 axs.color.INVERTED_YCC_MATRIX = axs.color.invert3x3Matrix(axs.color.YCC_MATRIX);28507 -128508 -1 axs.color.BLACK = new axs.color.Color(0, 0, 0, 1.0);28509 -1 axs.color.BLACK_YCC = axs.color.toYCbCr(axs.color.BLACK);28510 -1 axs.color.WHITE = new axs.color.Color(255, 255, 255, 1.0);28511 -1 axs.color.WHITE_YCC = axs.color.toYCbCr(axs.color.WHITE);28512 -1 axs.color.RED = new axs.color.Color(255, 0, 0, 1.0);28513 -1 axs.color.RED_YCC = axs.color.toYCbCr(axs.color.RED);28514 -1 axs.color.GREEN = new axs.color.Color(0, 255, 0, 1.0);28515 -1 axs.color.GREEN_YCC = axs.color.toYCbCr(axs.color.GREEN);28516 -1 axs.color.BLUE = new axs.color.Color(0, 0, 255, 1.0);28517 -1 axs.color.BLUE_YCC = axs.color.toYCbCr(axs.color.BLUE);28518 -1 axs.color.CYAN = new axs.color.Color(0, 255, 255, 1.0);28519 -1 axs.color.CYAN_YCC = axs.color.toYCbCr(axs.color.CYAN);28520 -1 axs.color.MAGENTA = new axs.color.Color(255, 0, 255, 1.0);28521 -1 axs.color.MAGENTA_YCC = axs.color.toYCbCr(axs.color.MAGENTA);28522 -1 axs.color.YELLOW = new axs.color.Color(255, 255, 0, 1.0);28523 -1 axs.color.YELLOW_YCC = axs.color.toYCbCr(axs.color.YELLOW);28524 -128525 -1 axs.color.YCC_CUBE_FACES_BLACK = [ { p0: axs.color.BLACK_YCC, p1: axs.color.RED_YCC, p2: axs.color.GREEN_YCC },28526 -1 { p0: axs.color.BLACK_YCC, p1: axs.color.GREEN_YCC, p2: axs.color.BLUE_YCC },28527 -1 { p0: axs.color.BLACK_YCC, p1: axs.color.BLUE_YCC, p2: axs.color.RED_YCC } ];28528 -1 axs.color.YCC_CUBE_FACES_WHITE = [ { p0: axs.color.WHITE_YCC, p1: axs.color.CYAN_YCC, p2: axs.color.MAGENTA_YCC },28529 -1 { p0: axs.color.WHITE_YCC, p1: axs.color.MAGENTA_YCC, p2: axs.color.YELLOW_YCC },28530 -1 { p0: axs.color.WHITE_YCC, p1: axs.color.YELLOW_YCC, p2: axs.color.CYAN_YCC } ];28531 -128532 -1 },{}],191:[function(require,module,exports){28533 -1 // Copyright 2012 Google Inc.28534 -1 //28535 -1 // Licensed under the Apache License, Version 2.0 (the "License");28536 -1 // you may not use this file except in compliance with the License.28537 -1 // You may obtain a copy of the License at28538 -1 //28539 -1 // http://www.apache.org/licenses/LICENSE-2.028540 -1 //28541 -1 // Unless required by applicable law or agreed to in writing, software28542 -1 // distributed under the License is distributed on an "AS IS" BASIS,28543 -1 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.28544 -1 // See the License for the specific language governing permissions and28545 -1 // limitations under the License.28546 -128547 -1 goog.provide('axs.constants');28548 -1 goog.provide('axs.constants.AuditResult');28549 -1 goog.provide('axs.constants.Severity');-1 2143 goog.provide('axs.constants'); -1 2144 goog.provide('axs.constants.AuditResult'); -1 2145 goog.provide('axs.constants.Severity'); 28550 2146 28551 2147 /** @type {Object.<string, Object>} */ 28552 2148 axs.constants.ARIA_ROLES = { @@ -30213,7 +3809,7 @@ axs.constants.TAG_TO_IMPLICIT_SEMANTIC_INFO = { 30213 3809 }] 30214 3810 }; 30215 381130216 -1 },{}],192:[function(require,module,exports){-1 3812 },{}],7:[function(require,module,exports){ 30217 3813 // Copyright 2015 Google Inc. 30218 3814 // 30219 3815 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -30427,7 +4023,7 @@ axs.dom.composedTreeSearch = function(node, end, callbacks, parentFlags, opt_sha 30427 4023 return found; 30428 4024 }; 30429 402530430 -1 },{}],193:[function(require,module,exports){-1 4026 },{}],8:[function(require,module,exports){ 30431 4027 // Copyright 2012 Google Inc. 30432 4028 // 30433 4029 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -31356,7 +4952,7 @@ axs.properties.getNativelySupportedAttributes = function(element) { 31356 4952 }; 31357 4953 })(); 31358 495431359 -1 },{}],194:[function(require,module,exports){-1 4955 },{}],9:[function(require,module,exports){ 31360 4956 var query = require('./lib/query.js'); 31361 4957 var name = require('./lib/name.js'); 31362 4958 var atree = require('./lib/atree.js'); @@ -31376,12 +4972,12 @@ module.exports = { 31376 4972 getChildNodes: atree.getChildNodes, 31377 4973 }; 31378 497431379 -1 },{"./lib/atree.js":195,"./lib/name.js":198,"./lib/query.js":199}],195:[function(require,module,exports){-1 4975 },{"./lib/atree.js":10,"./lib/name.js":13,"./lib/query.js":14}],10:[function(require,module,exports){ 31380 4976 var attrs = require('./attrs'); 31381 4977 31382 4978 var _getOwner = function(node) { 31383 4979 if (node.nodeType === node.ELEMENT_NODE && node.id) {31384 -1 var owner = document.querySelector('[aria-owns~="' + node.id + '"]');-1 4980 var owner = document.querySelector('[aria-owns~="' + CSS.escape(node.id) + '"]'); 31385 4981 if (owner) { 31386 4982 return owner; 31387 4983 } @@ -31404,7 +5000,7 @@ var detectLoop = function(node) { 31404 5000 31405 5001 var getOwner = function(node) { 31406 5002 if (node.nodeType === node.ELEMENT_NODE && node.id) {31407 -1 var owner = document.querySelector('[aria-owns~="' + node.id + '"]');-1 5003 var owner = document.querySelector('[aria-owns~="' + CSS.escape(node.id) + '"]'); 31408 5004 if (owner && !detectLoop(node)) { 31409 5005 return owner; 31410 5006 } @@ -31468,7 +5064,7 @@ module.exports = { 31468 5064 'searchUp': searchUp, 31469 5065 }; 31470 506631471 -1 },{"./attrs":196}],196:[function(require,module,exports){-1 5067 },{"./attrs":11}],11:[function(require,module,exports){ 31472 5068 var constants = require('./constants.js'); 31473 5069 31474 5070 // candidates can be passed for performance optimization @@ -31585,63 +5181,57 @@ module.exports = { 31585 5181 getAttribute: getAttribute, 31586 5182 }; 31587 518331588 -1 },{"./constants.js":197}],197:[function(require,module,exports){-1 5184 },{"./constants.js":12}],12:[function(require,module,exports){ -1 5185 // https://www.w3.org/TR/wai-aria/#state_prop_def 31589 5186 exports.attributes = {31590 -1 // widget-1 5187 'activedescendant': 'id', -1 5188 'atomic': 'bool', 31591 5189 'autocomplete': 'token', -1 5190 'busy': 'bool', 31592 5191 'checked': 'tristate', -1 5192 'colcount': 'int', -1 5193 'colindex': 'int', -1 5194 'colspan': 'int', -1 5195 'controls': 'id-list', 31593 5196 'current': 'token', -1 5197 'describedby': 'id-list', -1 5198 'details': 'id', 31594 5199 'disabled': 'bool', -1 5200 'dropeffect': 'token-list', -1 5201 'errormessage': 'id', 31595 5202 'expanded': 'bool-undefined', -1 5203 'flowto': 'id-list', -1 5204 'grabbed': 'bool-undefined', 31596 5205 'haspopup': 'token',31597 -1 'hidden': 'bool', // !-1 5206 'hidden': 'bool-undefined', 31598 5207 'invalid': 'token', 31599 5208 'keyshortcuts': 'string', 31600 5209 'label': 'string', -1 5210 'labelledby': 'id-list', 31601 5211 'level': 'int', -1 5212 'live': 'token', 31602 5213 'modal': 'bool', 31603 5214 'multiline': 'bool', 31604 5215 'multiselectable': 'bool', 31605 5216 'orientation': 'token', -1 5217 'owns': 'id-list', 31606 5218 'placeholder': 'string', -1 5219 'posinset': 'int', 31607 5220 'pressed': 'tristate', 31608 5221 'readonly': 'bool', -1 5222 'relevant': 'token-list', 31609 5223 'required': 'bool', 31610 5224 'roledescription': 'string',31611 -1 'selected': 'bool-undefined',31612 -1 'valuemax': 'number',31613 -1 'valuemin': 'number',31614 -1 'valuenow': 'number',31615 -1 'valuetext': 'string',31616 -131617 -1 // live31618 -1 'atomic': 'bool',31619 -1 'busy': 'bool',31620 -1 'live': 'token',31621 -1 'relevant': 'token-list',31622 -131623 -1 // dragndrop31624 -1 'dropeffect': 'token-list',31625 -1 'grabbed': 'bool-undefined',31626 -131627 -1 // relationship31628 -1 'activedescendant': 'id',31629 -1 'colcount': 'int',31630 -1 'colindex': 'int',31631 -1 'colspan': 'int',31632 -1 'controls': 'id-list',31633 -1 'describedby': 'id-list',31634 -1 'details': 'id',31635 -1 'errormessage': 'id',31636 -1 'flowto': 'id-list',31637 -1 'labelledby': 'id-list',31638 -1 'owns': 'id-list',31639 -1 'posinset': 'int',31640 5225 'rowcount': 'int', 31641 5226 'rowindex': 'int', 31642 5227 'rowspan': 'int', -1 5228 'selected': 'bool-undefined', 31643 5229 'setsize': 'int', 31644 5230 'sort': 'token', -1 5231 'valuemax': 'number', -1 5232 'valuemin': 'number', -1 5233 'valuenow': 'number', -1 5234 'valuetext': 'string', 31645 5235 }; 31646 5236 31647 5237 exports.attributeStrongMapping = { @@ -31687,6 +5277,7 @@ exports.roles = { 31687 5277 cell: { 31688 5278 selectors: ['td'], 31689 5279 childRoles: ['gridcell', 'rowheader'], -1 5280 nameFromContents: true, 31690 5281 }, 31691 5282 checkbox: { 31692 5283 selectors: ['input[type="checkbox"]'], @@ -31912,14 +5503,14 @@ exports.roles = { 31912 5503 selectors: ['tr'], 31913 5504 nameFromContents: true, 31914 5505 },31915 -1 rowheader: {31916 -1 selectors: ['th[scope="row"]'],31917 -1 nameFromContents: true,31918 -1 },31919 5506 rowgroup: { 31920 5507 selectors: ['tbody', 'thead', 'tfoot'], 31921 5508 nameFromContents: true, 31922 5509 }, -1 5510 rowheader: { -1 5511 selectors: ['th[scope="row"]'], -1 5512 nameFromContents: true, -1 5513 }, 31923 5514 scrollbar: { 31924 5515 defaults: { 31925 5516 'orientation': 'vertical', @@ -31976,13 +5567,11 @@ exports.roles = { 31976 5567 childRoles: ['combobox', 'listbox', 'menu', 'radiogroup', 'tree'], 31977 5568 }, 31978 5569 separator: { -1 5570 // assume not focussable because <hr> is not 31979 5571 selectors: ['hr'], 31980 5572 childRoles: ['doc-pagebreak'], 31981 5573 defaults: { 31982 5574 'orientation': 'horizontal',31983 -1 'valuemin': 0,31984 -1 'valuemax': 100,31985 -1 'valuenow': 50,31986 5575 }, 31987 5576 }, 31988 5577 slider: { @@ -32010,12 +5599,6 @@ exports.roles = { 32010 5599 'atomic': true, 32011 5600 }, 32012 5601 },32013 -1 switch: {32014 -1 nameFromContents: true,32015 -1 defaults: {32016 -1 'checked': false,32017 -1 },32018 -1 },32019 5602 structure: { 32020 5603 childRoles: [ 32021 5604 'application', @@ -32028,6 +5611,12 @@ exports.roles = { 32028 5611 'separator', 32029 5612 ], 32030 5613 }, -1 5614 switch: { -1 5615 nameFromContents: true, -1 5616 defaults: { -1 5617 'checked': false, -1 5618 }, -1 5619 }, 32031 5620 tab: { 32032 5621 nameFromContents: true, 32033 5622 defaults: { @@ -32082,7 +5671,6 @@ exports.roles = { 32082 5671 'input', 32083 5672 'range', 32084 5673 'row',32085 -1 'separator',32086 5674 'tab', 32087 5675 ], 32088 5676 }, @@ -32154,7 +5742,7 @@ exports.labelable = [ 32154 5742 'textarea', 32155 5743 ]; 32156 574432157 -1 },{}],198:[function(require,module,exports){-1 5745 },{}],13:[function(require,module,exports){ 32158 5746 var constants = require('./constants.js'); 32159 5747 var atree = require('./atree.js'); 32160 5748 var query = require('./query.js'); @@ -32354,7 +5942,7 @@ module.exports = { 32354 5942 getDescription: getDescription, 32355 5943 }; 32356 594432357 -1 },{"./atree.js":195,"./constants.js":197,"./query.js":199}],199:[function(require,module,exports){-1 5945 },{"./atree.js":10,"./constants.js":12,"./query.js":14}],14:[function(require,module,exports){ 32358 5946 var attrs = require('./attrs.js'); 32359 5947 var atree = require('./atree.js'); 32360 5948 @@ -32418,10 +6006,10 @@ module.exports = { 32418 6006 closest: closest, 32419 6007 }; 32420 600832421 -1 },{"./atree.js":195,"./attrs.js":196}],200:[function(require,module,exports){-1 6009 },{"./atree.js":10,"./attrs.js":11}],15:[function(require,module,exports){ 32422 6010 (function (process,setImmediate){(function (){32423 -1 /*! axe v4.2.332424 -1 * Copyright (c) 2021 Deque Systems, Inc.-1 6011 /*! axe v4.4.3 -1 6012 * Copyright (c) 2022 Deque Systems, Inc. 32425 6013 * 32426 6014 * Your use of this Source Code Form is subject to the terms of the Mozilla Public 32427 6015 * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -32437,19 +6025,14 @@ module.exports = { 32437 6025 'use strict'; 32438 6026 function _typeof(obj) { 32439 6027 '@babel/helpers - typeof';32440 -1 if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') {32441 -1 _typeof = function _typeof(obj) {32442 -1 return typeof obj;32443 -1 };32444 -1 } else {32445 -1 _typeof = function _typeof(obj) {32446 -1 return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj;32447 -1 };32448 -1 }32449 -1 return _typeof(obj);-1 6028 return _typeof = 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator ? function(obj) { -1 6029 return typeof obj; -1 6030 } : function(obj) { -1 6031 return obj && 'function' == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; -1 6032 }, _typeof(obj); 32450 6033 } 32451 6034 var axe = axe || {};32452 -1 axe.version = '4.2.3';-1 6035 axe.version = '4.4.3'; 32453 6036 if (typeof define === 'function' && define.amd) { 32454 6037 define('axe-core', [], function() { 32455 6038 return axe; @@ -32476,44 +6059,7 @@ module.exports = { 32476 6059 SupportError.prototype = Object.create(Error.prototype); 32477 6060 SupportError.prototype.constructor = SupportError; 32478 6061 'use strict';32479 -1 var _excluded = [ 'variant' ], _excluded2 = [ 'matches' ], _excluded3 = [ 'chromium' ], _excluded4 = [ 'noImplicit' ], _excluded5 = [ 'noPresentational' ];32480 -1 function _objectWithoutProperties(source, excluded) {32481 -1 if (source == null) {32482 -1 return {};32483 -1 }32484 -1 var target = _objectWithoutPropertiesLoose(source, excluded);32485 -1 var key, i;32486 -1 if (Object.getOwnPropertySymbols) {32487 -1 var sourceSymbolKeys = Object.getOwnPropertySymbols(source);32488 -1 for (i = 0; i < sourceSymbolKeys.length; i++) {32489 -1 key = sourceSymbolKeys[i];32490 -1 if (excluded.indexOf(key) >= 0) {32491 -1 continue;32492 -1 }32493 -1 if (!Object.prototype.propertyIsEnumerable.call(source, key)) {32494 -1 continue;32495 -1 }32496 -1 target[key] = source[key];32497 -1 }32498 -1 }32499 -1 return target;32500 -1 }32501 -1 function _objectWithoutPropertiesLoose(source, excluded) {32502 -1 if (source == null) {32503 -1 return {};32504 -1 }32505 -1 var target = {};32506 -1 var sourceKeys = Object.keys(source);32507 -1 var key, i;32508 -1 for (i = 0; i < sourceKeys.length; i++) {32509 -1 key = sourceKeys[i];32510 -1 if (excluded.indexOf(key) >= 0) {32511 -1 continue;32512 -1 }32513 -1 target[key] = source[key];32514 -1 }32515 -1 return target;32516 -1 }-1 6062 var _excluded = [ 'node' ], _excluded2 = [ 'node' ], _excluded3 = [ 'variant' ], _excluded4 = [ 'matches' ], _excluded5 = [ 'chromium' ], _excluded6 = [ 'noImplicit' ], _excluded7 = [ 'noPresentational' ], _excluded8 = [ 'nodes' ], _excluded9 = [ 'node' ], _excluded10 = [ 'relatedNodes' ], _excluded11 = [ 'environmentData' ], _excluded12 = [ 'environmentData' ], _excluded13 = [ 'node' ], _excluded14 = [ 'environmentData' ], _excluded15 = [ 'environmentData' ], _excluded16 = [ 'environmentData' ]; 32517 6063 function _defineProperty(obj, key, value) { 32518 6064 if (key in obj) { 32519 6065 Object.defineProperty(obj, key, { @@ -32538,6 +6084,9 @@ module.exports = { 32538 6084 configurable: true 32539 6085 } 32540 6086 }); -1 6087 Object.defineProperty(subClass, 'prototype', { -1 6088 writable: false -1 6089 }); 32541 6090 if (superClass) { 32542 6091 _setPrototypeOf(subClass, superClass); 32543 6092 } @@ -32565,6 +6114,8 @@ module.exports = { 32565 6114 function _possibleConstructorReturn(self, call) { 32566 6115 if (call && (_typeof(call) === 'object' || typeof call === 'function')) { 32567 6116 return call; -1 6117 } else if (call !== void 0) { -1 6118 throw new TypeError('Derived constructors may only return object or undefined'); 32568 6119 } 32569 6120 return _assertThisInitialized(self); 32570 6121 } @@ -32597,6 +6148,43 @@ module.exports = { 32597 6148 }; 32598 6149 return _getPrototypeOf(o); 32599 6150 } -1 6151 function _objectWithoutProperties(source, excluded) { -1 6152 if (source == null) { -1 6153 return {}; -1 6154 } -1 6155 var target = _objectWithoutPropertiesLoose(source, excluded); -1 6156 var key, i; -1 6157 if (Object.getOwnPropertySymbols) { -1 6158 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); -1 6159 for (i = 0; i < sourceSymbolKeys.length; i++) { -1 6160 key = sourceSymbolKeys[i]; -1 6161 if (excluded.indexOf(key) >= 0) { -1 6162 continue; -1 6163 } -1 6164 if (!Object.prototype.propertyIsEnumerable.call(source, key)) { -1 6165 continue; -1 6166 } -1 6167 target[key] = source[key]; -1 6168 } -1 6169 } -1 6170 return target; -1 6171 } -1 6172 function _objectWithoutPropertiesLoose(source, excluded) { -1 6173 if (source == null) { -1 6174 return {}; -1 6175 } -1 6176 var target = {}; -1 6177 var sourceKeys = Object.keys(source); -1 6178 var key, i; -1 6179 for (i = 0; i < sourceKeys.length; i++) { -1 6180 key = sourceKeys[i]; -1 6181 if (excluded.indexOf(key) >= 0) { -1 6182 continue; -1 6183 } -1 6184 target[key] = source[key]; -1 6185 } -1 6186 return target; -1 6187 } 32600 6188 function _toConsumableArray(arr) { 32601 6189 return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); 32602 6190 } @@ -32693,6 +6281,9 @@ module.exports = { 32693 6281 if (staticProps) { 32694 6282 _defineProperties(Constructor, staticProps); 32695 6283 } -1 6284 Object.defineProperty(Constructor, 'prototype', { -1 6285 writable: false -1 6286 }); 32696 6287 return Constructor; 32697 6288 } 32698 6289 function _createForOfIteratorHelper(o, allowArrayLike) { @@ -32781,16 +6372,11 @@ module.exports = { 32781 6372 } 32782 6373 function _typeof(obj) { 32783 6374 '@babel/helpers - typeof';32784 -1 if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') {32785 -1 _typeof = function _typeof(obj) {32786 -1 return typeof obj;32787 -1 };32788 -1 } else {32789 -1 _typeof = function _typeof(obj) {32790 -1 return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj;32791 -1 };32792 -1 }32793 -1 return _typeof(obj);-1 6375 return _typeof = 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator ? function(obj) { -1 6376 return typeof obj; -1 6377 } : function(obj) { -1 6378 return obj && 'function' == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; -1 6379 }, _typeof(obj); 32794 6380 } 32795 6381 (function() { 32796 6382 var __create = Object.create; @@ -33815,11 +7401,11 @@ module.exports = { 33815 7401 } else { 33816 7402 mixin = require_mixin(); 33817 7403 generate = function() {33818 -1 var cache20 = [];-1 7404 var cache21 = []; 33819 7405 return function(length) { 33820 7406 var args, i = 0;33821 -1 if (cache20[length]) {33822 -1 return cache20[length];-1 7407 if (cache21[length]) { -1 7408 return cache21[length]; 33823 7409 } 33824 7410 args = []; 33825 7411 while (length--) { @@ -34638,7 +8224,7 @@ module.exports = { 34638 8224 var _on = ee.on; 34639 8225 var emit = ee.emit; 34640 8226 module.exports = function(original, length, options) {34641 -1 var cache20 = create(null), conf, memLength, _get, set, del, _clear, extDel, extGet, extHas, normalizer, getListeners, setListeners, deleteListeners, memoized, resolve;-1 8227 var cache21 = create(null), conf, memLength, _get, set, del, _clear, extDel, extGet, extHas, normalizer, getListeners, setListeners, deleteListeners, memoized, resolve; 34642 8228 if (length !== false) { 34643 8229 memLength = length; 34644 8230 } else if (isNaN(original.length)) { @@ -34664,11 +8250,11 @@ module.exports = { 34664 8250 } 34665 8251 id = _get(args); 34666 8252 if (id !== null) {34667 -1 if (hasOwnProperty.call(cache20, id)) {-1 8253 if (hasOwnProperty.call(cache21, id)) { 34668 8254 if (getListeners) { 34669 8255 conf.emit('get', id, args, this); 34670 8256 }34671 -1 return cache20[id];-1 8257 return cache21[id]; 34672 8258 } 34673 8259 } 34674 8260 if (args.length === 1) { @@ -34682,10 +8268,10 @@ module.exports = { 34682 8268 throw customError('Circular invocation', 'CIRCULAR_INVOCATION'); 34683 8269 } 34684 8270 id = set(args);34685 -1 } else if (hasOwnProperty.call(cache20, id)) {-1 8271 } else if (hasOwnProperty.call(cache21, id)) { 34686 8272 throw customError('Circular invocation', 'CIRCULAR_INVOCATION'); 34687 8273 }34688 -1 cache20[id] = result;-1 8274 cache21[id] = result; 34689 8275 if (setListeners) { 34690 8276 conf.emit('set', id, null, result); 34691 8277 } @@ -34694,21 +8280,21 @@ module.exports = { 34694 8280 } else if (length === 0) { 34695 8281 memoized = function memoized() { 34696 8282 var result;34697 -1 if (hasOwnProperty.call(cache20, 'data')) {-1 8283 if (hasOwnProperty.call(cache21, 'data')) { 34698 8284 if (getListeners) { 34699 8285 conf.emit('get', 'data', arguments, this); 34700 8286 }34701 -1 return cache20.data;-1 8287 return cache21.data; 34702 8288 } 34703 8289 if (arguments.length) { 34704 8290 result = apply.call(original, this, arguments); 34705 8291 } else { 34706 8292 result = call.call(original, this); 34707 8293 }34708 -1 if (hasOwnProperty.call(cache20, 'data')) {-1 8294 if (hasOwnProperty.call(cache21, 'data')) { 34709 8295 throw customError('Circular invocation', 'CIRCULAR_INVOCATION'); 34710 8296 }34711 -1 cache20.data = result;-1 8297 cache21.data = result; 34712 8298 if (setListeners) { 34713 8299 conf.emit('set', 'data', null, result); 34714 8300 } @@ -34721,21 +8307,21 @@ module.exports = { 34721 8307 args = resolve(arguments); 34722 8308 } 34723 8309 id = String(args[0]);34724 -1 if (hasOwnProperty.call(cache20, id)) {-1 8310 if (hasOwnProperty.call(cache21, id)) { 34725 8311 if (getListeners) { 34726 8312 conf.emit('get', id, args, this); 34727 8313 }34728 -1 return cache20[id];-1 8314 return cache21[id]; 34729 8315 } 34730 8316 if (args.length === 1) { 34731 8317 result = call.call(original, this, args[0]); 34732 8318 } else { 34733 8319 result = apply.call(original, this, args); 34734 8320 }34735 -1 if (hasOwnProperty.call(cache20, id)) {-1 8321 if (hasOwnProperty.call(cache21, id)) { 34736 8322 throw customError('Circular invocation', 'CIRCULAR_INVOCATION'); 34737 8323 }34738 -1 cache20[id] = result;-1 8324 cache21[id] = result; 34739 8325 if (setListeners) { 34740 8326 conf.emit('set', id, null, result); 34741 8327 } @@ -34756,28 +8342,28 @@ module.exports = { 34756 8342 return String(args[0]); 34757 8343 }, 34758 8344 has: function has(id) {34759 -1 return hasOwnProperty.call(cache20, id);-1 8345 return hasOwnProperty.call(cache21, id); 34760 8346 }, 34761 8347 delete: function _delete(id) { 34762 8348 var result;34763 -1 if (!hasOwnProperty.call(cache20, id)) {-1 8349 if (!hasOwnProperty.call(cache21, id)) { 34764 8350 return; 34765 8351 } 34766 8352 if (del) { 34767 8353 del(id); 34768 8354 }34769 -1 result = cache20[id];34770 -1 delete cache20[id];-1 8355 result = cache21[id]; -1 8356 delete cache21[id]; 34771 8357 if (deleteListeners) { 34772 8358 conf.emit('delete', id, result); 34773 8359 } 34774 8360 }, 34775 8361 clear: function clear() {34776 -1 var oldCache = cache20;-1 8362 var oldCache = cache21; 34777 8363 if (_clear) { 34778 8364 _clear(); 34779 8365 }34780 -1 cache20 = create(null);-1 8366 cache21 = create(null); 34781 8367 conf.emit('clear', oldCache); 34782 8368 }, 34783 8369 on: function on(type, listener) { @@ -34822,7 +8408,7 @@ module.exports = { 34822 8408 extGet = defineLength(function() { 34823 8409 var id, args = arguments; 34824 8410 if (length === 0) {34825 -1 return cache20.data;-1 8411 return cache21.data; 34826 8412 } 34827 8413 if (resolve) { 34828 8414 args = resolve(args); @@ -34832,7 +8418,7 @@ module.exports = { 34832 8418 } else { 34833 8419 id = String(args[0]); 34834 8420 }34835 -1 return cache20[id];-1 8421 return cache21[id]; 34836 8422 }); 34837 8423 extHas = defineLength(function() { 34838 8424 var id, args = arguments; @@ -34983,7 +8569,7 @@ module.exports = { 34983 8569 var indexOf = require_e_index_of(); 34984 8570 var create = Object.create; 34985 8571 module.exports = function() {34986 -1 var lastId = 0, map = [], cache20 = create(null);-1 8572 var lastId = 0, map = [], cache21 = create(null); 34987 8573 return { 34988 8574 get: function get(args) { 34989 8575 var index = 0, set = map, i, length = args.length; @@ -35031,11 +8617,11 @@ module.exports = { 35031 8617 } 35032 8618 set[1][i] = ++lastId; 35033 8619 }35034 -1 cache20[lastId] = args;-1 8620 cache21[lastId] = args; 35035 8621 return lastId; 35036 8622 }, 35037 8623 delete: function _delete(id) {35038 -1 var index = 0, set = map, i, args = cache20[id], length = args.length, path = [];-1 8624 var index = 0, set = map, i, args = cache21[id], length = args.length, path = []; 35039 8625 if (length === 0) { 35040 8626 delete set[length]; 35041 8627 } else if (set = set[length]) { @@ -35062,11 +8648,11 @@ module.exports = { 35062 8648 set[1].splice(i, 1); 35063 8649 } 35064 8650 }35065 -1 delete cache20[id];-1 8651 delete cache21[id]; 35066 8652 }, 35067 8653 clear: function clear() { 35068 8654 map = [];35069 -1 cache20 = create(null);-1 8655 cache21 = create(null); 35070 8656 } 35071 8657 }; 35072 8658 }; @@ -35075,27 +8661,27 @@ module.exports = { 35075 8661 'use strict'; 35076 8662 var indexOf = require_e_index_of(); 35077 8663 module.exports = function() {35078 -1 var lastId = 0, argsMap = [], cache20 = [];-1 8664 var lastId = 0, argsMap = [], cache21 = []; 35079 8665 return { 35080 8666 get: function get(args) { 35081 8667 var index = indexOf.call(argsMap, args[0]);35082 -1 return index === -1 ? null : cache20[index];-1 8668 return index === -1 ? null : cache21[index]; 35083 8669 }, 35084 8670 set: function set(args) { 35085 8671 argsMap.push(args[0]);35086 -1 cache20.push(++lastId);-1 8672 cache21.push(++lastId); 35087 8673 return lastId; 35088 8674 }, 35089 8675 delete: function _delete(id) {35090 -1 var index = indexOf.call(cache20, id);-1 8676 var index = indexOf.call(cache21, id); 35091 8677 if (index !== -1) { 35092 8678 argsMap.splice(index, 1);35093 -1 cache20.splice(index, 1);-1 8679 cache21.splice(index, 1); 35094 8680 } 35095 8681 }, 35096 8682 clear: function clear() { 35097 8683 argsMap = [];35098 -1 cache20 = [];-1 8684 cache21 = []; 35099 8685 } 35100 8686 }; 35101 8687 }; @@ -35105,7 +8691,7 @@ module.exports = { 35105 8691 var indexOf = require_e_index_of(); 35106 8692 var create = Object.create; 35107 8693 module.exports = function(length) {35108 -1 var lastId = 0, map = [ [], [] ], cache20 = create(null);-1 8694 var lastId = 0, map = [ [], [] ], cache21 = create(null); 35109 8695 return { 35110 8696 get: function get(args) { 35111 8697 var index = 0, set = map, i; @@ -35139,11 +8725,11 @@ module.exports = { 35139 8725 i = set[0].push(args[index]) - 1; 35140 8726 } 35141 8727 set[1][i] = ++lastId;35142 -1 cache20[lastId] = args;-1 8728 cache21[lastId] = args; 35143 8729 return lastId; 35144 8730 }, 35145 8731 delete: function _delete(id) {35146 -1 var index = 0, set = map, i, path = [], args = cache20[id];-1 8732 var index = 0, set = map, i, path = [], args = cache21[id]; 35147 8733 while (index < length - 1) { 35148 8734 i = indexOf.call(set[0], args[index]); 35149 8735 if (i === -1) { @@ -35166,11 +8752,11 @@ module.exports = { 35166 8752 set[0].splice(i, 1); 35167 8753 set[1].splice(i, 1); 35168 8754 }35169 -1 delete cache20[id];-1 8755 delete cache21[id]; 35170 8756 }, 35171 8757 clear: function clear() { 35172 8758 map = [ [], [] ];35173 -1 cache20 = create(null);-1 8759 cache21 = create(null); 35174 8760 } 35175 8761 }; 35176 8762 }; @@ -35283,7 +8869,7 @@ module.exports = { 35283 8869 var apply = Function.prototype.apply; 35284 8870 var create = Object.create; 35285 8871 require_registered_extensions().async = function(tbi, conf) {35286 -1 var waiting = create(null), cache20 = create(null), base = conf.memoized, original = conf.original, currentCallback, currentContext, currentArgs;-1 8872 var waiting = create(null), cache21 = create(null), base = conf.memoized, original = conf.original, currentCallback, currentContext, currentArgs; 35287 8873 conf.memoized = defineLength(function(arg) { 35288 8874 var args = arguments, last = args[args.length - 1]; 35289 8875 if (typeof last === 'function') { @@ -35296,7 +8882,7 @@ module.exports = { 35296 8882 mixin(conf.memoized, base); 35297 8883 } catch (ignore) {} 35298 8884 conf.on('get', function(id) {35299 -1 var cb, context3, args;-1 8885 var cb, context5, args; 35300 8886 if (!currentCallback) { 35301 8887 return; 35302 8888 } @@ -35310,20 +8896,20 @@ module.exports = { 35310 8896 return; 35311 8897 } 35312 8898 cb = currentCallback;35313 -1 context3 = currentContext;-1 8899 context5 = currentContext; 35314 8900 args = currentArgs; 35315 8901 currentCallback = currentContext = currentArgs = null; 35316 8902 nextTick(function() { 35317 8903 var data2;35318 -1 if (hasOwnProperty.call(cache20, id)) {35319 -1 data2 = cache20[id];35320 -1 conf.emit('getasync', id, args, context3);-1 8904 if (hasOwnProperty.call(cache21, id)) { -1 8905 data2 = cache21[id]; -1 8906 conf.emit('getasync', id, args, context5); 35321 8907 apply.call(cb, data2.context, data2.args); 35322 8908 } else { 35323 8909 currentCallback = cb;35324 -1 currentContext = context3;-1 8910 currentContext = context5; 35325 8911 currentArgs = args;35326 -1 base.apply(context3, args);-1 8912 base.apply(context5, args); 35327 8913 } 35328 8914 }); 35329 8915 }); @@ -35350,7 +8936,7 @@ module.exports = { 35350 8936 if (err2) { 35351 8937 conf['delete'](id); 35352 8938 } else {35353 -1 cache20[id] = {-1 8939 cache21[id] = { 35354 8940 context: this, 35355 8941 args: args2 35356 8942 }; @@ -35397,16 +8983,16 @@ module.exports = { 35397 8983 if (hasOwnProperty.call(waiting, id)) { 35398 8984 return; 35399 8985 }35400 -1 if (!cache20[id]) {-1 8986 if (!cache21[id]) { 35401 8987 return; 35402 8988 }35403 -1 result = cache20[id];35404 -1 delete cache20[id];-1 8989 result = cache21[id]; -1 8990 delete cache21[id]; 35405 8991 conf.emit('deleteasync', id, slice.call(result.args, 1)); 35406 8992 }); 35407 8993 conf.on('clear', function() {35408 -1 var oldCache = cache20;35409 -1 cache20 = create(null);-1 8994 var oldCache = cache21; -1 8995 cache21 = create(null); 35410 8996 conf.emit('clearasync', objectMap(oldCache, function(data2) { 35411 8997 return slice.call(data2.args, 1); 35412 8998 })); @@ -35500,7 +9086,7 @@ module.exports = { 35500 9086 var create = Object.create; 35501 9087 var supportedModes = primitiveSet('then', 'then:finally', 'done', 'done:finally'); 35502 9088 require_registered_extensions().promise = function(mode, conf) {35503 -1 var waiting = create(null), cache20 = create(null), promises = create(null);-1 9089 var waiting = create(null), cache21 = create(null), promises = create(null); 35504 9090 if (mode === true) { 35505 9091 mode = null; 35506 9092 } else { @@ -35512,7 +9098,7 @@ module.exports = { 35512 9098 conf.on('set', function(id, ignore, promise) { 35513 9099 var isFailed = false; 35514 9100 if (!isPromise(promise)) {35515 -1 cache20[id] = promise;-1 9101 cache21[id] = promise; 35516 9102 conf.emit('setasync', id, 1); 35517 9103 return; 35518 9104 } @@ -35527,7 +9113,7 @@ module.exports = { 35527 9113 return; 35528 9114 } 35529 9115 delete waiting[id];35530 -1 cache20[id] = result;-1 9116 cache21[id] = result; 35531 9117 conf.emit('setasync', id, count); 35532 9118 }; 35533 9119 var onFailure = function onFailure() { @@ -35569,7 +9155,7 @@ module.exports = { 35569 9155 promise['finally'](onFailure); 35570 9156 } 35571 9157 });35572 -1 conf.on('get', function(id, args, context3) {-1 9158 conf.on('get', function(id, args, context5) { 35573 9159 var promise; 35574 9160 if (waiting[id]) { 35575 9161 ++waiting[id]; @@ -35577,7 +9163,7 @@ module.exports = { 35577 9163 } 35578 9164 promise = promises[id]; 35579 9165 var emit = function emit() {35580 -1 conf.emit('getasync', id, args, context3);-1 9166 conf.emit('getasync', id, args, context5); 35581 9167 }; 35582 9168 if (isPromise(promise)) { 35583 9169 if (typeof promise.done === 'function') { @@ -35597,16 +9183,16 @@ module.exports = { 35597 9183 delete waiting[id]; 35598 9184 return; 35599 9185 }35600 -1 if (!hasOwnProperty.call(cache20, id)) {-1 9186 if (!hasOwnProperty.call(cache21, id)) { 35601 9187 return; 35602 9188 }35603 -1 var result = cache20[id];35604 -1 delete cache20[id];-1 9189 var result = cache21[id]; -1 9190 delete cache21[id]; 35605 9191 conf.emit('deleteasync', id, [ result ]); 35606 9192 }); 35607 9193 conf.on('clear', function() {35608 -1 var oldCache = cache20;35609 -1 cache20 = create(null);-1 9194 var oldCache = cache21; -1 9195 cache21 = create(null); 35610 9196 waiting = create(null); 35611 9197 promises = create(null); 35612 9198 conf.emit('clearasync', objectMap(oldCache, function(data2) { @@ -35628,8 +9214,8 @@ module.exports = { 35628 9214 conf.on('deleteasync', del = function del(id, resultArray) { 35629 9215 apply.call(dispose, null, resultArray); 35630 9216 });35631 -1 conf.on('clearasync', function(cache20) {35632 -1 forEach(cache20, function(result, id) {-1 9217 conf.on('clearasync', function(cache21) { -1 9218 forEach(cache21, function(result, id) { 35633 9219 del(id, result); 35634 9220 }); 35635 9221 }); @@ -35638,8 +9224,8 @@ module.exports = { 35638 9224 conf.on('delete', del = function del(id, result) { 35639 9225 dispose(result); 35640 9226 });35641 -1 conf.on('clear', function(cache20) {35642 -1 forEach(cache20, function(result, id) {-1 9227 conf.on('clear', function(cache21) { -1 9228 forEach(cache21, function(result, id) { 35643 9229 del(id, result); 35644 9230 }); 35645 9231 }); @@ -35669,7 +9255,7 @@ module.exports = { 35669 9255 var isPromise = require_is_promise(); 35670 9256 var timeout = require_valid_timeout(); 35671 9257 var extensions = require_registered_extensions();35672 -1 var noop4 = Function.prototype;-1 9258 var noop3 = Function.prototype; 35673 9259 var max = Math.max; 35674 9260 var min = Math.min; 35675 9261 var create = Object.create; @@ -35723,7 +9309,7 @@ module.exports = { 35723 9309 if (preFetchAge) { 35724 9310 preFetchTimeouts = {}; 35725 9311 preFetchAge = (1 - preFetchAge) * maxAge;35726 -1 conf.on('get' + postfix, function(id, args, context3) {-1 9312 conf.on('get' + postfix, function(id, args, context5) { 35727 9313 if (!preFetchTimeouts[id]) { 35728 9314 preFetchTimeouts[id] = 'nextTick'; 35729 9315 nextTick(function() { @@ -35735,15 +9321,15 @@ module.exports = { 35735 9321 conf['delete'](id); 35736 9322 if (options.async) { 35737 9323 args = aFrom(args);35738 -1 args.push(noop4);-1 9324 args.push(noop3); 35739 9325 }35740 -1 result = conf.memoized.apply(context3, args);-1 9326 result = conf.memoized.apply(context5, args); 35741 9327 if (options.promise) { 35742 9328 if (isPromise(result)) { 35743 9329 if (typeof result.done === 'function') {35744 -1 result.done(noop4, noop4);-1 9330 result.done(noop3, noop3); 35745 9331 } else {35746 -1 result.then(noop4, noop4);-1 9332 result.then(noop3, noop3); 35747 9333 } 35748 9334 } 35749 9335 } @@ -35860,20 +9446,20 @@ module.exports = { 35860 9446 var create = Object.create; 35861 9447 var defineProperties = Object.defineProperties; 35862 9448 extensions.refCounter = function(ignore, conf, options) {35863 -1 var cache20, postfix;35864 -1 cache20 = create(null);-1 9449 var cache21, postfix; -1 9450 cache21 = create(null); 35865 9451 postfix = options.async && extensions.async || options.promise && extensions.promise ? 'async' : ''; 35866 9452 conf.on('set' + postfix, function(id, length) {35867 -1 cache20[id] = length || 1;-1 9453 cache21[id] = length || 1; 35868 9454 }); 35869 9455 conf.on('get' + postfix, function(id) {35870 -1 ++cache20[id];-1 9456 ++cache21[id]; 35871 9457 }); 35872 9458 conf.on('delete' + postfix, function(id) {35873 -1 delete cache20[id];-1 9459 delete cache21[id]; 35874 9460 }); 35875 9461 conf.on('clear' + postfix, function() {35876 -1 cache20 = {};-1 9462 cache21 = {}; 35877 9463 }); 35878 9464 defineProperties(conf.memoized, { 35879 9465 deleteRef: d(function() { @@ -35881,10 +9467,10 @@ module.exports = { 35881 9467 if (id === null) { 35882 9468 return null; 35883 9469 }35884 -1 if (!cache20[id]) {-1 9470 if (!cache21[id]) { 35885 9471 return null; 35886 9472 }35887 -1 if (!--cache20[id]) {-1 9473 if (!--cache21[id]) { 35888 9474 conf['delete'](id); 35889 9475 return true; 35890 9476 } @@ -35895,10 +9481,10 @@ module.exports = { 35895 9481 if (id === null) { 35896 9482 return 0; 35897 9483 }35898 -1 if (!cache20[id]) {-1 9484 if (!cache21[id]) { 35899 9485 return 0; 35900 9486 }35901 -1 return cache20[id];-1 9487 return cache21[id]; 35902 9488 }) 35903 9489 }); 35904 9490 }; @@ -36248,7 +9834,7 @@ module.exports = { 36248 9834 } 36249 9835 function then(onFulfillment, onRejection) { 36250 9836 var parent = this;36251 -1 var child = new this.constructor(noop4);-1 9837 var child = new this.constructor(noop3); 36252 9838 if (child[PROMISE_ID] === void 0) { 36253 9839 makePromise(child); 36254 9840 } @@ -36268,12 +9854,12 @@ module.exports = { 36268 9854 if (object && _typeof(object) === 'object' && object.constructor === Constructor) { 36269 9855 return object; 36270 9856 }36271 -1 var promise = new Constructor(noop4);-1 9857 var promise = new Constructor(noop3); 36272 9858 resolve(promise, object); 36273 9859 return promise; 36274 9860 } 36275 9861 var PROMISE_ID = Math.random().toString(36).substring(2);36276 -1 function noop4() {}-1 9862 function noop3() {} 36277 9863 var PENDING = void 0; 36278 9864 var FULFILLED = 1; 36279 9865 var REJECTED = 2; @@ -36464,7 +10050,7 @@ module.exports = { 36464 10050 var Enumerator = function() { 36465 10051 function Enumerator2(Constructor, input) { 36466 10052 this._instanceConstructor = Constructor;36467 -1 this.promise = new Constructor(noop4);-1 10053 this.promise = new Constructor(noop3); 36468 10054 if (!this.promise[PROMISE_ID]) { 36469 10055 makePromise(this.promise); 36470 10056 } @@ -36509,7 +10095,7 @@ module.exports = { 36509 10095 this._remaining--; 36510 10096 this._result[i] = entry; 36511 10097 } else if (c === Promise$1) {36512 -1 var promise = new c(noop4);-1 10098 var promise = new c(noop3); 36513 10099 if (didError) { 36514 10100 reject(promise, error); 36515 10101 } else { @@ -36569,7 +10155,7 @@ module.exports = { 36569 10155 } 36570 10156 function reject$1(reason) { 36571 10157 var Constructor = this;36572 -1 var promise = new Constructor(noop4);-1 10158 var promise = new Constructor(noop3); 36573 10159 reject(promise, reason); 36574 10160 return promise; 36575 10161 } @@ -36584,7 +10170,7 @@ module.exports = { 36584 10170 this[PROMISE_ID] = nextId(); 36585 10171 this._result = this._state = void 0; 36586 10172 this._subscribers = [];36587 -1 if (noop4 !== resolver) {-1 10173 if (noop3 !== resolver) { 36588 10174 typeof resolver !== 'function' && needsResolver(); 36589 10175 this instanceof Promise2 ? initializePromise(this, resolver) : needsNew(); 36590 10176 } @@ -36677,7 +10263,7 @@ module.exports = { 36677 10263 var LN2 = Math.LN2; 36678 10264 var abs = Math.abs; 36679 10265 var floor = Math.floor;36680 -1 var log10 = Math.log;-1 10266 var log9 = Math.log; 36681 10267 var min = Math.min; 36682 10268 var pow = Math.pow; 36683 10269 var round = Math.round; @@ -36833,7 +10419,7 @@ module.exports = { 36833 10419 s = v < 0; 36834 10420 v = abs(v); 36835 10421 if (v >= pow(2, 1 - bias)) {36836 -1 e = min(floor(log10(v) / LN2), 1023);-1 10422 e = min(floor(log9(v) / LN2), 1023); 36837 10423 f = roundToEven(v / pow(2, e) * pow(2, fbits)); 36838 10424 if (f / pow(2, fbits) >= 2) { 36839 10425 e = e + 1; @@ -37062,7 +10648,7 @@ module.exports = { 37062 10648 } 37063 10649 }; 37064 10650 _ctor.prototype.subarray = function(start, end) {37065 -1 function clamp(v, min2, max) {-1 10651 function clamp2(v, min2, max) { 37066 10652 return v < min2 ? min2 : v > max ? max : v; 37067 10653 } 37068 10654 start = ECMAScript.ToInt32(start); @@ -37079,8 +10665,8 @@ module.exports = { 37079 10665 if (end < 0) { 37080 10666 end = this.length + end; 37081 10667 }37082 -1 start = clamp(start, 0, this.length);37083 -1 end = clamp(end, 0, this.length);-1 10668 start = clamp2(start, 0, this.length); -1 10669 end = clamp2(end, 0, this.length); 37084 10670 var len = end - start; 37085 10671 if (len < 0) { 37086 10672 len = 0; @@ -37421,10 +11007,10 @@ module.exports = { 37421 11007 return closest_default; 37422 11008 }, 37423 11009 collectResultsFromFrames: function collectResultsFromFrames() {37424 -1 return collect_results_from_frames_default;-1 11010 return _collectResultsFromFrames; 37425 11011 }, 37426 11012 contains: function contains() {37427 -1 return contains_default;-1 11013 return _contains; 37428 11014 }, 37429 11015 convertSelector: function convertSelector() { 37430 11016 return _convertSelector; @@ -37465,9 +11051,15 @@ module.exports = { 37465 11051 getCheckOption: function getCheckOption() { 37466 11052 return get_check_option_default; 37467 11053 }, -1 11054 getEnvironmentData: function getEnvironmentData() { -1 11055 return _getEnvironmentData; -1 11056 }, 37468 11057 getFlattenedTree: function getFlattenedTree() { 37469 11058 return get_flattened_tree_default; 37470 11059 }, -1 11060 getFrameContexts: function getFrameContexts() { -1 11061 return _getFrameContexts; -1 11062 }, 37471 11063 getFriendlyUriEnd: function getFriendlyUriEnd() { 37472 11064 return get_friendly_uri_end_default; 37473 11065 }, @@ -37487,7 +11079,7 @@ module.exports = { 37487 11079 return get_rule_default; 37488 11080 }, 37489 11081 getScroll: function getScroll() {37490 -1 return get_scroll_default;-1 11082 return _getScroll; 37491 11083 }, 37492 11084 getScrollState: function getScrollState() { 37493 11085 return get_scroll_state_default; @@ -37531,6 +11123,9 @@ module.exports = { 37531 11123 isXHTML: function isXHTML() { 37532 11124 return is_xhtml_default; 37533 11125 }, -1 11126 matchAncestry: function matchAncestry() { -1 11127 return match_ancestry_default; -1 11128 }, 37534 11129 matches: function matches() { 37535 11130 return matches_default; 37536 11131 }, @@ -37598,11 +11193,14 @@ module.exports = { 37598 11193 return select_default; 37599 11194 }, 37600 11195 sendCommandToFrame: function sendCommandToFrame() {37601 -1 return send_command_to_frame_default;-1 11196 return _sendCommandToFrame; 37602 11197 }, 37603 11198 setScrollState: function setScrollState() { 37604 11199 return set_scroll_state_default; 37605 11200 }, -1 11201 shadowSelect: function shadowSelect() { -1 11202 return _shadowSelect; -1 11203 }, 37606 11204 shouldPreload: function shouldPreload() { 37607 11205 return _shouldPreload; 37608 11206 }, @@ -37667,7 +11265,7 @@ module.exports = { 37667 11265 }; 37668 11266 } 37669 11267 function isRespondableMessage(postedMessage) {37670 -1 return _typeof(postedMessage) === 'object' && typeof postedMessage.channelId === 'string' && postedMessage.source === getSource();-1 11268 return postedMessage !== null && _typeof(postedMessage) === 'object' && typeof postedMessage.channelId === 'string' && postedMessage.source === getSource(); 37671 11269 } 37672 11270 function buildErrorObject(error) { 37673 11271 var msg = error.message || 'Unknown error occurred'; @@ -37731,14 +11329,6 @@ module.exports = { 37731 11329 return _rnds8; 37732 11330 }; 37733 11331 }37734 -1 try {37735 -1 if (!_rng) {37736 -1 var nodeCrypto = require('crypto');37737 -1 _rng = function _rng() {37738 -1 return nodeCrypto.randomBytes(16);37739 -1 };37740 -1 }37741 -1 } catch (e) {}37742 11332 if (!_rng) { 37743 11333 var _rnds = new Array(16); 37744 11334 _rng = function _rng() { @@ -37921,25 +11511,30 @@ module.exports = { 37921 11511 } 37922 11512 function messageHandler(_ref2, topicHandler) { 37923 11513 var origin = _ref2.origin, dataString = _ref2.data, win = _ref2.source;37924 -1 var data2 = parseMessage(dataString) || {};37925 -1 var channelId = data2.channelId, message = data2.message, messageId = data2.messageId;37926 -1 if (!originIsAllowed(origin) || !isNewMessage(messageId)) {37927 -1 return;37928 -1 }37929 -1 if (message instanceof Error && win.parent !== window) {37930 -1 axe.log(message);37931 -1 return false;37932 -1 }37933 11514 try {37934 -1 if (data2.topic) {37935 -1 var responder = createResponder(win, channelId);37936 -1 assertIsParentWindow(win);37937 -1 topicHandler(data2, responder);37938 -1 } else {37939 -1 callReplyHandler(win, data2);-1 11515 var data2 = parseMessage(dataString) || {}; -1 11516 var channelId = data2.channelId, message = data2.message, messageId = data2.messageId; -1 11517 if (!originIsAllowed(origin) || !isNewMessage(messageId)) { -1 11518 return; -1 11519 } -1 11520 if (message instanceof Error && win.parent !== window) { -1 11521 axe.log(message); -1 11522 return false; -1 11523 } -1 11524 try { -1 11525 if (data2.topic) { -1 11526 var responder = createResponder(win, channelId); -1 11527 assertIsParentWindow(win); -1 11528 topicHandler(data2, responder); -1 11529 } else { -1 11530 callReplyHandler(win, data2); -1 11531 } -1 11532 } catch (error) { -1 11533 processError(win, error, channelId); 37940 11534 } 37941 11535 } catch (error) {37942 -1 processError(win, error, channelId);-1 11536 axe.log(error); -1 11537 return false; 37943 11538 } 37944 11539 } 37945 11540 function callReplyHandler(win, data2) { @@ -38355,23 +11950,23 @@ module.exports = { 38355 11950 var xhtml; 38356 11951 var ignoredAttributes = [ 'class', 'style', 'id', 'selected', 'checked', 'disabled', 'tabindex', 'aria-checked', 'aria-selected', 'aria-invalid', 'aria-activedescendant', 'aria-busy', 'aria-disabled', 'aria-expanded', 'aria-grabbed', 'aria-pressed', 'aria-valuenow' ]; 38357 11952 var MAXATTRIBUTELENGTH = 31; -1 11953 var attrCharsRegex = /([\\"])/g; -1 11954 var newlineChars = /(\r\n|\r|\n)/g; -1 11955 function escapeAttribute(str) { -1 11956 return str.replace(attrCharsRegex, '\\$1').replace(newlineChars, '\\a '); -1 11957 } 38358 11958 function getAttributeNameValue(node, at) { 38359 11959 var name = at.name; 38360 11960 var atnv; 38361 11961 if (name.indexOf('href') !== -1 || name.indexOf('src') !== -1) { 38362 11962 var friendly = get_friendly_uri_end_default(node.getAttribute(name)); 38363 11963 if (friendly) {38364 -1 var value = encodeURI(friendly);38365 -1 if (value) {38366 -1 atnv = escape_selector_default(at.name) + '$="' + escape_selector_default(value) + '"';38367 -1 } else {38368 -1 return;38369 -1 }-1 11964 atnv = escape_selector_default(at.name) + '$="' + escapeAttribute(friendly) + '"'; 38370 11965 } else {38371 -1 atnv = escape_selector_default(at.name) + '="' + escape_selector_default(node.getAttribute(name)) + '"';-1 11966 atnv = escape_selector_default(at.name) + '="' + escapeAttribute(node.getAttribute(name)) + '"'; 38372 11967 } 38373 11968 } else {38374 -1 atnv = escape_selector_default(name) + '="' + escape_selector_default(at.value) + '"';-1 11969 atnv = escape_selector_default(name) + '="' + escapeAttribute(at.value) + '"'; 38375 11970 } 38376 11971 return atnv; 38377 11972 } @@ -38745,13 +12340,16 @@ module.exports = { 38745 12340 } 38746 12341 }; 38747 12342 DqElement.fromFrame = function fromFrame(node, options, frame) {38748 -1 var spec = _extends({}, node, {-1 12343 var spec = DqElement.mergeSpecs(node, frame); -1 12344 return new DqElement(frame.element, options, spec); -1 12345 }; -1 12346 DqElement.mergeSpecs = function mergeSpec(node, frame) { -1 12347 return _extends({}, node, { 38749 12348 selector: [].concat(_toConsumableArray(frame.selector), _toConsumableArray(node.selector)), 38750 12349 ancestry: [].concat(_toConsumableArray(frame.ancestry), _toConsumableArray(node.ancestry)), 38751 12350 xpath: [].concat(_toConsumableArray(frame.xpath), _toConsumableArray(node.xpath)), 38752 12351 nodeIndexes: [].concat(_toConsumableArray(frame.nodeIndexes), _toConsumableArray(node.nodeIndexes)) 38753 12352 });38754 -1 return new DqElement(frame.element, options, spec);38755 12353 }; 38756 12354 var dq_element_default = DqElement; 38757 12355 function checkHelper(checkResult, options, resolve, reject) { @@ -38772,7 +12370,15 @@ module.exports = { 38772 12370 checkResult.data = data2; 38773 12371 }, 38774 12372 relatedNodes: function relatedNodes(nodes) { -1 12373 if (!window.Node) { -1 12374 return; -1 12375 } 38775 12376 nodes = nodes instanceof window.Node ? [ nodes ] : to_array_default(nodes); -1 12377 if (!nodes.every(function(node) { -1 12378 return node instanceof window.Node || node.actualNode; -1 12379 })) { -1 12380 return; -1 12381 } 38776 12382 checkResult.relatedNodes = nodes.map(function(element) { 38777 12383 return new dq_element_default(element, options); 38778 12384 }); @@ -38781,7 +12387,11 @@ module.exports = { 38781 12387 } 38782 12388 var check_helper_default = checkHelper; 38783 12389 function clone(obj) { -1 12390 var _window, _window2; 38784 12391 var index, length, out = obj; -1 12392 if ((_window = window) !== null && _window !== void 0 && _window.Node && obj instanceof window.Node || (_window2 = window) !== null && _window2 !== void 0 && _window2.HTMLCollection && obj instanceof window.HTMLCollection) { -1 12393 return obj; -1 12394 } 38785 12395 if (obj !== null && _typeof(obj) === 'object') { 38786 12396 if (Array.isArray(obj)) { 38787 12397 out = []; @@ -38968,22 +12578,25 @@ module.exports = { 38968 12578 expressions = expressions.selectors ? expressions.selectors : [ expressions ]; 38969 12579 return convertExpressions(expressions); 38970 12580 }38971 -1 function _matchesExpression(vNode, expressions, matchAnyParent) {38972 -1 var exps = [].concat(expressions);38973 -1 var expression = exps.pop();-1 12581 function optimizedMatchesExpression(vNode, expressions, index, matchAnyParent) { -1 12582 var isArray = Array.isArray(expressions); -1 12583 var expression = isArray ? expressions[index] : expressions; 38974 12584 var matches14 = matchExpression(vNode, expression); 38975 12585 while (!matches14 && matchAnyParent && vNode.parent) { 38976 12586 vNode = vNode.parent; 38977 12587 matches14 = matchExpression(vNode, expression); 38978 12588 }38979 -1 if (exps.length) {-1 12589 if (index > 0) { 38980 12590 if ([ ' ', '>' ].includes(expression.combinator) === false) { 38981 12591 throw new Error('axe.utils.matchesExpression does not support the combinator: ' + expression.combinator); 38982 12592 }38983 -1 matches14 = matches14 && _matchesExpression(vNode.parent, exps, expression.combinator === ' ');-1 12593 matches14 = matches14 && optimizedMatchesExpression(vNode.parent, expressions, index - 1, expression.combinator === ' '); 38984 12594 } 38985 12595 return matches14; 38986 12596 } -1 12597 function _matchesExpression(vNode, expressions, matchAnyParent) { -1 12598 return optimizedMatchesExpression(vNode, expressions, expressions.length - 1, matchAnyParent); -1 12599 } 38987 12600 function matches(vNode, selector) { 38988 12601 var expressions = _convertSelector(selector); 38989 12602 return expressions.some(function(expression) { @@ -39154,20 +12767,19 @@ module.exports = { 39154 12767 return !!win.frameElement; 39155 12768 }; 39156 12769 setDefaultFrameMessenger(_respondable);39157 -1 function err(message, node) {39158 -1 var selector;39159 -1 if (axe._tree) {39160 -1 selector = _getSelector(node);39161 -1 }39162 -1 return new Error(message + ': ' + (selector || node));39163 -1 }39164 -1 function sendCommandToFrame(node, parameters, resolve, reject) {-1 12770 function _sendCommandToFrame(node, parameters, resolve, reject) { -1 12771 var _parameters$options$p, _parameters$options; 39165 12772 var win = node.contentWindow; -1 12773 var pingWaitTime = (_parameters$options$p = (_parameters$options = parameters.options) === null || _parameters$options === void 0 ? void 0 : _parameters$options.pingWaitTime) !== null && _parameters$options$p !== void 0 ? _parameters$options$p : 500; 39166 12774 if (!win) { 39167 12775 log_default('Frame does not have a content window', node); 39168 12776 resolve(null); 39169 12777 return; 39170 12778 } -1 12779 if (pingWaitTime === 0) { -1 12780 callAxeStart(node, parameters, resolve, reject); -1 12781 return; -1 12782 } 39171 12783 var timeout = setTimeout(function() { 39172 12784 timeout = setTimeout(function() { 39173 12785 if (!parameters.debug) { @@ -39176,24 +12788,35 @@ module.exports = { 39176 12788 reject(err('No response from frame', node)); 39177 12789 } 39178 12790 }, 0);39179 -1 }, 500);-1 12791 }, pingWaitTime); 39180 12792 _respondable(win, 'axe.ping', null, void 0, function() { 39181 12793 clearTimeout(timeout);39182 -1 var frameWaitTime = parameters.options && parameters.options.frameWaitTime || 6e4;39183 -1 timeout = setTimeout(function collectResultFramesTimeout() {39184 -1 reject(err('Axe in frame timed out', node));39185 -1 }, frameWaitTime);39186 -1 _respondable(win, 'axe.start', parameters, void 0, function(data2) {39187 -1 clearTimeout(timeout);39188 -1 if (data2 instanceof Error === false) {39189 -1 resolve(data2);39190 -1 } else {39191 -1 reject(data2);39192 -1 }39193 -1 });-1 12794 callAxeStart(node, parameters, resolve, reject); 39194 12795 }); 39195 12796 }39196 -1 var send_command_to_frame_default = sendCommandToFrame;-1 12797 function callAxeStart(node, parameters, resolve, reject) { -1 12798 var _parameters$options$f, _parameters$options2; -1 12799 var frameWaitTime = (_parameters$options$f = (_parameters$options2 = parameters.options) === null || _parameters$options2 === void 0 ? void 0 : _parameters$options2.frameWaitTime) !== null && _parameters$options$f !== void 0 ? _parameters$options$f : 6e4; -1 12800 var win = node.contentWindow; -1 12801 var timeout = setTimeout(function collectResultFramesTimeout() { -1 12802 reject(err('Axe in frame timed out', node)); -1 12803 }, frameWaitTime); -1 12804 _respondable(win, 'axe.start', parameters, void 0, function(data2) { -1 12805 clearTimeout(timeout); -1 12806 if (data2 instanceof Error === false) { -1 12807 resolve(data2); -1 12808 } else { -1 12809 reject(data2); -1 12810 } -1 12811 }); -1 12812 } -1 12813 function err(message, node) { -1 12814 var selector; -1 12815 if (axe._tree) { -1 12816 selector = _getSelector(node); -1 12817 } -1 12818 return new Error(message + ': ' + (selector || node)); -1 12819 } 39197 12820 function getAllChecks(object) { 39198 12821 var result = []; 39199 12822 return result.concat(object.any || []).concat(object.all || []).concat(object.none || []); @@ -39207,13 +12830,13 @@ module.exports = { 39207 12830 } 39208 12831 } 39209 12832 var find_by_default = findBy;39210 -1 function pushFrame(resultSet, dqFrame, options) {-1 12833 function pushFrame(resultSet, options, frameSpec) { 39211 12834 resultSet.forEach(function(res) {39212 -1 res.node = dq_element_default.fromFrame(res.node, options, dqFrame);-1 12835 res.node = dq_element_default.fromFrame(res.node, options, frameSpec); 39213 12836 var checks = get_all_checks_default(res); 39214 12837 checks.forEach(function(check4) { 39215 12838 check4.relatedNodes = check4.relatedNodes.map(function(node) {39216 -1 return dq_element_default.fromFrame(node, options, dqFrame);-1 12839 return dq_element_default.fromFrame(node, options, frameSpec); 39217 12840 }); 39218 12841 }); 39219 12842 }); @@ -39249,16 +12872,10 @@ module.exports = { 39249 12872 if (!results || !results.length) { 39250 12873 return; 39251 12874 }39252 -1 var dqFrame;39253 -1 if (frameResult.frameElement) {39254 -1 var spec = {39255 -1 selector: [ frameResult.frame ]39256 -1 };39257 -1 dqFrame = new dq_element_default(frameResult.frameElement, options, spec);39258 -1 }-1 12875 var frameSpec = getFrameSpec(frameResult, options); 39259 12876 results.forEach(function(ruleResult) {39260 -1 if (ruleResult.nodes && dqFrame) {39261 -1 pushFrame(ruleResult.nodes, dqFrame, options);-1 12877 if (ruleResult.nodes && frameSpec) { -1 12878 pushFrame(ruleResult.nodes, options, frameSpec); 39262 12879 } 39263 12880 var res = find_by_default(mergedResult, 'id', ruleResult.id); 39264 12881 if (!res) { @@ -39299,79 +12916,66 @@ module.exports = { 39299 12916 return 0; 39300 12917 } 39301 12918 var merge_results_default = mergeResults;39302 -1 function collectResultsFromFrames(parentContent, options, command, parameter, resolve, reject) {-1 12919 function getFrameSpec(frameResult, options) { -1 12920 if (frameResult.frameElement) { -1 12921 return new dq_element_default(frameResult.frameElement, options); -1 12922 } else if (frameResult.frameSpec) { -1 12923 return frameResult.frameSpec; -1 12924 } -1 12925 return null; -1 12926 } -1 12927 function _collectResultsFromFrames(parentContent, options, command, parameter, resolve, reject) { 39303 12928 var q = queue_default(); 39304 12929 var frames = parentContent.frames;39305 -1 frames.forEach(function(frame) {39306 -1 var tabindex = parseInt(frame.node.getAttribute('tabindex'), 10);39307 -1 var focusable = isNaN(tabindex) || tabindex >= 0;39308 -1 var rect = frame.node.getBoundingClientRect();39309 -1 var width = parseInt(frame.node.getAttribute('width'), 10);39310 -1 var height = parseInt(frame.node.getAttribute('height'), 10);39311 -1 width = isNaN(width) ? rect.width : width;39312 -1 height = isNaN(height) ? rect.height : height;39313 -1 var params = {39314 -1 options: options,39315 -1 command: command,39316 -1 parameter: parameter,39317 -1 context: {39318 -1 initiator: false,39319 -1 focusable: parentContent.focusable === false ? false : focusable,39320 -1 boundingClientRect: {39321 -1 width: width,39322 -1 height: height39323 -1 },39324 -1 page: parentContent.page,39325 -1 include: frame.include || [],39326 -1 exclude: frame.exclude || []39327 -1 }39328 -1 };-1 12930 frames.forEach(function(_ref6) { -1 12931 var frameElement = _ref6.node, context5 = _objectWithoutProperties(_ref6, _excluded); 39329 12932 q.defer(function(res, rej) {39330 -1 var node = frame.node;39331 -1 send_command_to_frame_default(node, params, function(data2) {39332 -1 if (data2) {39333 -1 return res({39334 -1 results: data2,39335 -1 frameElement: node,39336 -1 frame: _getSelector(node)39337 -1 });-1 12933 var params = { -1 12934 options: options, -1 12935 command: command, -1 12936 parameter: parameter, -1 12937 context: context5 -1 12938 }; -1 12939 function callback(results) { -1 12940 if (!results) { -1 12941 return res(null); 39338 12942 }39339 -1 res(null);39340 -1 }, rej);-1 12943 return res({ -1 12944 results: results, -1 12945 frameElement: frameElement -1 12946 }); -1 12947 } -1 12948 _sendCommandToFrame(frameElement, params, callback, rej); 39341 12949 }); 39342 12950 }); 39343 12951 q.then(function(data2) { 39344 12952 resolve(merge_results_default(data2, options)); 39345 12953 })['catch'](reject); 39346 12954 }39347 -1 var collect_results_from_frames_default = collectResultsFromFrames;39348 -1 function contains(vNode, otherVNode) {39349 -1 function containsShadowChild(vNode2, otherVNode2) {39350 -1 if (vNode2.shadowId === otherVNode2.shadowId) {39351 -1 return true;39352 -1 }39353 -1 return !!vNode2.children.find(function(child) {39354 -1 return containsShadowChild(child, otherVNode2);39355 -1 });39356 -1 }-1 12955 function _contains(vNode, otherVNode) { 39357 12956 if (vNode.shadowId || otherVNode.shadowId) {39358 -1 return containsShadowChild(vNode, otherVNode);-1 12957 do { -1 12958 if (vNode.shadowId === otherVNode.shadowId) { -1 12959 return true; -1 12960 } -1 12961 otherVNode = otherVNode.parent; -1 12962 } while (otherVNode); -1 12963 return false; 39359 12964 }39360 -1 if (vNode.actualNode) {39361 -1 if (typeof vNode.actualNode.contains === 'function') {39362 -1 return vNode.actualNode.contains(otherVNode.actualNode);39363 -1 }39364 -1 return !!(vNode.actualNode.compareDocumentPosition(otherVNode.actualNode) & 16);39365 -1 } else {-1 12965 if (!vNode.actualNode) { 39366 12966 do { 39367 12967 if (otherVNode === vNode) { 39368 12968 return true; 39369 12969 }39370 -1 } while (otherVNode = otherVNode && otherVNode.parent);-1 12970 otherVNode = otherVNode.parent; -1 12971 } while (otherVNode); 39371 12972 }39372 -1 return false;-1 12973 if (typeof vNode.actualNode.contains !== 'function') { -1 12974 var position = vNode.actualNode.compareDocumentPosition(otherVNode.actualNode); -1 12975 return !!(position & 16); -1 12976 } -1 12977 return vNode.actualNode.contains(otherVNode.actualNode); 39373 12978 }39374 -1 var contains_default = contains;39375 12979 function deepMerge() { 39376 12980 var target = {}; 39377 12981 for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) { @@ -39466,6 +13070,9 @@ module.exports = { 39466 13070 insertedIntoFocusOrder: function insertedIntoFocusOrder() { 39467 13071 return inserted_into_focus_order_default; 39468 13072 }, -1 13073 isCurrentPageLink: function isCurrentPageLink() { -1 13074 return _isCurrentPageLink; -1 13075 }, 39469 13076 isFocusable: function isFocusable() { 39470 13077 return is_focusable_default; 39471 13078 }, @@ -39494,7 +13101,7 @@ module.exports = { 39494 13101 return is_opaque_default; 39495 13102 }, 39496 13103 isSkipLink: function isSkipLink() {39497 -1 return is_skip_link_default;-1 13104 return _isSkipLink; 39498 13105 }, 39499 13106 isVisible: function isVisible() { 39500 13107 return is_visible_default; @@ -39512,7 +13119,7 @@ module.exports = { 39512 13119 return url_props_from_attribute_default; 39513 13120 }, 39514 13121 visuallyContains: function visuallyContains() {39515 -1 return visually_contains_default;-1 13122 return _visuallyContains; 39516 13123 }, 39517 13124 visuallyOverlaps: function visuallyOverlaps() { 39518 13125 return visually_overlaps_default; @@ -39527,14 +13134,14 @@ module.exports = { 39527 13134 } 39528 13135 var get_root_node_default = getRootNode; 39529 13136 var get_root_node_default2 = get_root_node_default;39530 -1 function findElmsInContext(_ref6) {39531 -1 var context3 = _ref6.context, value = _ref6.value, attr = _ref6.attr, _ref6$elm = _ref6.elm, elm = _ref6$elm === void 0 ? '' : _ref6$elm;-1 13137 function findElmsInContext(_ref7) { -1 13138 var context5 = _ref7.context, value = _ref7.value, attr = _ref7.attr, _ref7$elm = _ref7.elm, elm = _ref7$elm === void 0 ? '' : _ref7$elm; 39532 13139 var root; 39533 13140 var escapedValue = escape_selector_default(value);39534 -1 if (context3.nodeType === 9 || context3.nodeType === 11) {39535 -1 root = context3;-1 13141 if (context5.nodeType === 9 || context5.nodeType === 11) { -1 13142 root = context5; 39536 13143 } else {39537 -1 root = get_root_node_default2(context3);-1 13144 root = get_root_node_default2(context5); 39538 13145 } 39539 13146 return Array.from(root.querySelectorAll(elm + '[' + attr + '=' + escapedValue + ']')); 39540 13147 } @@ -39582,15 +13189,51 @@ module.exports = { 39582 13189 return null; 39583 13190 } 39584 13191 var get_composed_parent_default = getComposedParent; -1 13192 var angularSkipLinkRegex = /^\/\#/; -1 13193 var angularRouterLinkRegex = /^#[!/]/; -1 13194 function _isCurrentPageLink(anchor) { -1 13195 var _window$location; -1 13196 var href = anchor.getAttribute('href'); -1 13197 if (!href || href === '#') { -1 13198 return false; -1 13199 } -1 13200 if (angularSkipLinkRegex.test(href)) { -1 13201 return true; -1 13202 } -1 13203 var hash = anchor.hash, protocol = anchor.protocol, hostname = anchor.hostname, port = anchor.port, pathname = anchor.pathname; -1 13204 if (angularRouterLinkRegex.test(hash)) { -1 13205 return false; -1 13206 } -1 13207 if (href.charAt(0) === '#') { -1 13208 return true; -1 13209 } -1 13210 if (typeof ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.origin) !== 'string' || window.location.origin.indexOf('://') === -1) { -1 13211 return null; -1 13212 } -1 13213 var currentPageUrl = window.location.origin + window.location.pathname; -1 13214 var url; -1 13215 if (!hostname) { -1 13216 url = window.location.origin; -1 13217 } else { -1 13218 url = ''.concat(protocol, '//').concat(hostname).concat(port ? ':'.concat(port) : ''); -1 13219 } -1 13220 if (!pathname) { -1 13221 url += window.location.pathname; -1 13222 } else { -1 13223 url += (pathname[0] !== '/' ? '/' : '') + pathname; -1 13224 } -1 13225 return url === currentPageUrl; -1 13226 } 39585 13227 function getElementByReference(node, attr) { 39586 13228 var fragment = node.getAttribute(attr); 39587 13229 if (!fragment) { 39588 13230 return null; 39589 13231 }39590 -1 if (fragment.charAt(0) === '#') {39591 -1 fragment = decodeURIComponent(fragment.substring(1));39592 -1 } else if (fragment.substr(0, 2) === '/#') {39593 -1 fragment = decodeURIComponent(fragment.substring(2));-1 13232 if (attr === 'href' && !_isCurrentPageLink(node)) { -1 13233 return null; -1 13234 } -1 13235 if (fragment.indexOf('#') !== -1) { -1 13236 fragment = decodeURIComponent(fragment.substr(fragment.indexOf('#') + 1)); 39594 13237 } 39595 13238 var candidate = document.getElementById(fragment); 39596 13239 if (candidate) { @@ -39698,7 +13341,10 @@ module.exports = { 39698 13341 var matchesClip = style.getPropertyValue('clip').match(clipRegex); 39699 13342 var matchesClipPath = style.getPropertyValue('clip-path').match(clipPathRegex); 39700 13343 if (matchesClip && matchesClip.length === 5) {39701 -1 return matchesClip[3] - matchesClip[1] <= 0 && matchesClip[2] - matchesClip[4] <= 0;-1 13344 var position = style.getPropertyValue('position'); -1 13345 if ([ 'fixed', 'absolute' ].includes(position)) { -1 13346 return matchesClip[3] - matchesClip[1] <= 0 && matchesClip[2] - matchesClip[4] <= 0; -1 13347 } 39702 13348 } 39703 13349 if (matchesClipPath) { 39704 13350 var type = matchesClipPath[1]; @@ -39732,44 +13378,68 @@ module.exports = { 39732 13378 if (!refs || !refs.length) { 39733 13379 return false; 39734 13380 }39735 -1 return refs.some(function(_ref7) {39736 -1 var actualNode = _ref7.actualNode;-1 13381 return refs.some(function(_ref8) { -1 13382 var actualNode = _ref8.actualNode; 39737 13383 return isVisible(actualNode, screenReader, recursed); 39738 13384 }); 39739 13385 } 39740 13386 function isVisible(el, screenReader, recursed) { -1 13387 var _window$Node; 39741 13388 if (!el) { 39742 13389 throw new TypeError('Cannot determine if element is visible for non-DOM nodes'); 39743 13390 }39744 -1 var vNode = get_node_from_tree_default(el);-1 13391 var vNode = el instanceof abstract_virtual_node_default ? el : get_node_from_tree_default(el); -1 13392 el = vNode ? vNode.actualNode : el; 39745 13393 var cacheName = '_isVisible' + (screenReader ? 'ScreenReader' : '');39746 -1 if (el.nodeType === 9) {-1 13394 var _ref9 = (_window$Node = window.Node) !== null && _window$Node !== void 0 ? _window$Node : {}, DOCUMENT_NODE = _ref9.DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE = _ref9.DOCUMENT_FRAGMENT_NODE; -1 13395 var nodeType = vNode ? vNode.props.nodeType : el.nodeType; -1 13396 var nodeName2 = vNode ? vNode.props.nodeName : el.nodeName.toLowerCase(); -1 13397 if (vNode && typeof vNode[cacheName] !== 'undefined') { -1 13398 return vNode[cacheName]; -1 13399 } -1 13400 if (nodeType === DOCUMENT_NODE) { 39747 13401 return true; 39748 13402 }39749 -1 if (el.nodeType === 11) {-1 13403 if ([ 'style', 'script', 'noscript', 'template' ].includes(nodeName2)) { -1 13404 return false; -1 13405 } -1 13406 if (el && nodeType === DOCUMENT_FRAGMENT_NODE) { 39750 13407 el = el.host; 39751 13408 }39752 -1 if (vNode && typeof vNode[cacheName] !== 'undefined') {39753 -1 return vNode[cacheName];-1 13409 if (screenReader) { -1 13410 var ariaHiddenValue = vNode ? vNode.attr('aria-hidden') : el.getAttribute('aria-hidden'); -1 13411 if (ariaHiddenValue === 'true') { -1 13412 return false; -1 13413 } -1 13414 } -1 13415 if (!el) { -1 13416 var parent2 = vNode.parent; -1 13417 var visible5 = true; -1 13418 if (parent2) { -1 13419 visible5 = isVisible(parent2, screenReader, true); -1 13420 } -1 13421 if (vNode) { -1 13422 vNode[cacheName] = visible5; -1 13423 } -1 13424 return visible5; 39754 13425 } 39755 13426 var style = window.getComputedStyle(el, null); 39756 13427 if (style === null) { 39757 13428 return false; 39758 13429 }39759 -1 var nodeName2 = el.nodeName.toUpperCase();39760 -1 if (nodeName2 === 'AREA') {-1 13430 if (nodeName2 === 'area') { 39761 13431 return isAreaVisible(el, screenReader, recursed); 39762 13432 }39763 -1 if (style.getPropertyValue('display') === 'none' || [ 'STYLE', 'SCRIPT', 'NOSCRIPT', 'TEMPLATE' ].includes(nodeName2)) {39764 -1 return false;39765 -1 }39766 -1 if (screenReader && el.getAttribute('aria-hidden') === 'true') {-1 13433 if (style.getPropertyValue('display') === 'none') { 39767 13434 return false; 39768 13435 } 39769 13436 var elHeight = parseInt(style.getPropertyValue('height'));39770 -1 var scrollableWithZeroHeight = get_scroll_default(el) && elHeight === 0;39771 -1 var posAbsoluteOverflowHiddenAndSmall = style.getPropertyValue('position') === 'absolute' && elHeight < 2 && style.getPropertyValue('overflow') === 'hidden';39772 -1 if (!screenReader && (isClipped(style) || style.getPropertyValue('opacity') === '0' || scrollableWithZeroHeight || posAbsoluteOverflowHiddenAndSmall)) {-1 13437 var elWidth = parseInt(style.getPropertyValue('width')); -1 13438 var scroll = _getScroll(el); -1 13439 var scrollableWithZeroHeight = scroll && elHeight === 0; -1 13440 var scrollableWithZeroWidth = scroll && elWidth === 0; -1 13441 var posAbsoluteOverflowHiddenAndSmall = style.getPropertyValue('position') === 'absolute' && (elHeight < 2 || elWidth < 2) && style.getPropertyValue('overflow') === 'hidden'; -1 13442 if (!screenReader && (isClipped(style) || style.getPropertyValue('opacity') === '0' || scrollableWithZeroHeight || scrollableWithZeroWidth || posAbsoluteOverflowHiddenAndSmall)) { 39773 13443 return false; 39774 13444 } 39775 13445 if (!recursed && (style.getPropertyValue('visibility') === 'hidden' || !screenReader && is_offscreen_default(el))) { @@ -39787,6 +13457,90 @@ module.exports = { 39787 13457 } 39788 13458 var is_visible_default = isVisible; 39789 13459 var gridSize = 200; -1 13460 function createGrid() { -1 13461 var root = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.body; -1 13462 var rootGrid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { -1 13463 container: null, -1 13464 cells: [] -1 13465 }; -1 13466 var parentVNode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; -1 13467 if (!parentVNode) { -1 13468 var vNode = get_node_from_tree_default(document.documentElement); -1 13469 if (!vNode) { -1 13470 vNode = new virtual_node_default(document.documentElement); -1 13471 } -1 13472 vNode._stackingOrder = [ 0 ]; -1 13473 addNodeToGrid(rootGrid, vNode); -1 13474 if (_getScroll(vNode.actualNode)) { -1 13475 var subGrid = { -1 13476 container: vNode, -1 13477 cells: [] -1 13478 }; -1 13479 vNode._subGrid = subGrid; -1 13480 } -1 13481 } -1 13482 var treeWalker = document.createTreeWalker(root, window.NodeFilter.SHOW_ELEMENT, null, false); -1 13483 var node = parentVNode ? treeWalker.nextNode() : treeWalker.currentNode; -1 13484 while (node) { -1 13485 var _vNode = get_node_from_tree_default(node); -1 13486 if (node.parentElement) { -1 13487 parentVNode = get_node_from_tree_default(node.parentElement); -1 13488 } else if (node.parentNode && get_node_from_tree_default(node.parentNode)) { -1 13489 parentVNode = get_node_from_tree_default(node.parentNode); -1 13490 } -1 13491 if (!_vNode) { -1 13492 _vNode = new axe.VirtualNode(node, parentVNode); -1 13493 } -1 13494 _vNode._stackingOrder = getStackingOrder(_vNode, parentVNode); -1 13495 var scrollRegionParent = findScrollRegionParent(_vNode, parentVNode); -1 13496 var grid = scrollRegionParent ? scrollRegionParent._subGrid : rootGrid; -1 13497 if (_getScroll(_vNode.actualNode)) { -1 13498 var _subGrid = { -1 13499 container: _vNode, -1 13500 cells: [] -1 13501 }; -1 13502 _vNode._subGrid = _subGrid; -1 13503 } -1 13504 var rect = _vNode.boundingClientRect; -1 13505 if (rect.width !== 0 && rect.height !== 0 && is_visible_default(node)) { -1 13506 addNodeToGrid(grid, _vNode); -1 13507 } -1 13508 if (is_shadow_root_default(node)) { -1 13509 createGrid(node.shadowRoot, grid, _vNode); -1 13510 } -1 13511 node = treeWalker.nextNode(); -1 13512 } -1 13513 } -1 13514 function getRectStack(grid, rect) { -1 13515 var _grid$cells$row$col$f, _grid$cells$row$col; -1 13516 var recursed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; -1 13517 var x = rect.left + rect.width / 2; -1 13518 var y = rect.top + rect.height / 2; -1 13519 var row = y / gridSize | 0; -1 13520 var col = x / gridSize | 0; -1 13521 if (row > grid.cells.length || col > grid.numCols) { -1 13522 throw new Error('Element midpoint exceeds the grid bounds'); -1 13523 } -1 13524 var stack = (_grid$cells$row$col$f = (_grid$cells$row$col = grid.cells[row][col]) === null || _grid$cells$row$col === void 0 ? void 0 : _grid$cells$row$col.filter(function(gridCellNode) { -1 13525 return gridCellNode.clientRects.find(function(clientRect) { -1 13526 var rectX = clientRect.left; -1 13527 var rectY = clientRect.top; -1 13528 return x <= rectX + clientRect.width && x >= rectX && y <= rectY + clientRect.height && y >= rectY; -1 13529 }); -1 13530 })) !== null && _grid$cells$row$col$f !== void 0 ? _grid$cells$row$col$f : []; -1 13531 var gridContainer = grid.container; -1 13532 if (gridContainer) { -1 13533 stack = getRectStack(gridContainer._grid, gridContainer.boundingClientRect, true).concat(stack); -1 13534 } -1 13535 if (!recursed) { -1 13536 stack = stack.sort(visuallySort).map(function(vNode) { -1 13537 return vNode.actualNode; -1 13538 }).concat(document.documentElement).filter(function(node, index, array) { -1 13539 return array.indexOf(node) === index; -1 13540 }); -1 13541 } -1 13542 return stack; -1 13543 } 39790 13544 function isStackingContext(vNode, parentVNode) { 39791 13545 var position = vNode.getComputedStylePropertyValue('position'); 39792 13546 var zIndex = vNode.getComputedStylePropertyValue('z-index'); @@ -39870,21 +13624,21 @@ module.exports = { 39870 13624 return floated; 39871 13625 } 39872 13626 function getPositionOrder(vNode) {39873 -1 if (vNode.getComputedStylePropertyValue('position') === 'static') {39874 -1 if (vNode.getComputedStylePropertyValue('display').indexOf('inline') !== -1) {39875 -1 return 2;39876 -1 }39877 -1 if (isFloated(vNode)) {39878 -1 return 1;39879 -1 }39880 -1 return 0;-1 13627 if (vNode.getComputedStylePropertyValue('display').indexOf('inline') !== -1) { -1 13628 return 2; -1 13629 } -1 13630 if (isFloated(vNode)) { -1 13631 return 1; 39881 13632 }39882 -1 return 3;-1 13633 return 0; 39883 13634 } 39884 13635 function visuallySort(a, b) {39885 -1 for (var _i5 = 0; _i5 < a._stackingOrder.length; _i5++) {-1 13636 var length = Math.max(a._stackingOrder.length, b._stackingOrder.length); -1 13637 for (var _i5 = 0; _i5 < length; _i5++) { 39886 13638 if (typeof b._stackingOrder[_i5] === 'undefined') { 39887 13639 return -1; -1 13640 } else if (typeof a._stackingOrder[_i5] === 'undefined') { -1 13641 return 1; 39888 13642 } 39889 13643 if (b._stackingOrder[_i5] > a._stackingOrder[_i5]) { 39890 13644 return 1; @@ -39916,7 +13670,7 @@ module.exports = { 39916 13670 return a.actualNode.getRootNode() !== aNode.getRootNode() ? -1 : 1; 39917 13671 } 39918 13672 }39919 -1 var _window$Node = window.Node, DOCUMENT_POSITION_FOLLOWING = _window$Node.DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_CONTAINS = _window$Node.DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_CONTAINED_BY = _window$Node.DOCUMENT_POSITION_CONTAINED_BY;-1 13673 var _window$Node2 = window.Node, DOCUMENT_POSITION_FOLLOWING = _window$Node2.DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_CONTAINS = _window$Node2.DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_CONTAINED_BY = _window$Node2.DOCUMENT_POSITION_CONTAINED_BY; 39920 13674 var docPosition = aNode.compareDocumentPosition(bNode); 39921 13675 var DOMOrder = docPosition & DOCUMENT_POSITION_FOLLOWING ? 1 : -1; 39922 13676 var isDescendant = docPosition & DOCUMENT_POSITION_CONTAINS || docPosition & DOCUMENT_POSITION_CONTAINED_BY; @@ -39930,11 +13684,25 @@ module.exports = { 39930 13684 function getStackingOrder(vNode, parentVNode) { 39931 13685 var stackingOrder = parentVNode._stackingOrder.slice(); 39932 13686 var zIndex = vNode.getComputedStylePropertyValue('z-index');39933 -1 if (zIndex !== 'auto') {-1 13687 var positioned = vNode.getComputedStylePropertyValue('position') !== 'static'; -1 13688 var floated = vNode.getComputedStylePropertyValue('float') !== 'none'; -1 13689 if (positioned && ![ 'auto', '0' ].includes(zIndex)) { -1 13690 while (stackingOrder.find(function(value) { -1 13691 return value % 1 !== 0; -1 13692 })) { -1 13693 var index = stackingOrder.findIndex(function(value) { -1 13694 return value % 1 !== 0; -1 13695 }); -1 13696 stackingOrder.splice(index, 1); -1 13697 } 39934 13698 stackingOrder[stackingOrder.length - 1] = parseInt(zIndex); 39935 13699 } 39936 13700 if (isStackingContext(vNode, parentVNode)) { 39937 13701 stackingOrder.push(0); -1 13702 } else if (positioned) { -1 13703 stackingOrder.push(.5); -1 13704 } else if (floated) { -1 13705 stackingOrder.push(.25); 39938 13706 } 39939 13707 return stackingOrder; 39940 13708 } @@ -39942,12 +13710,12 @@ module.exports = { 39942 13710 var scrollRegionParent = null; 39943 13711 var checkedNodes = [ vNode ]; 39944 13712 while (parentVNode) {39945 -1 if (parentVNode._scrollRegionParent) {39946 -1 scrollRegionParent = parentVNode._scrollRegionParent;-1 13713 if (_getScroll(parentVNode.actualNode)) { -1 13714 scrollRegionParent = parentVNode; 39947 13715 break; 39948 13716 }39949 -1 if (get_scroll_default(parentVNode.actualNode)) {39950 -1 scrollRegionParent = parentVNode;-1 13717 if (parentVNode._scrollRegionParent) { -1 13718 scrollRegionParent = parentVNode._scrollRegionParent; 39951 13719 break; 39952 13720 } 39953 13721 checkedNodes.push(parentVNode); @@ -39961,12 +13729,14 @@ module.exports = { 39961 13729 function addNodeToGrid(grid, vNode) { 39962 13730 vNode._grid = grid; 39963 13731 vNode.clientRects.forEach(function(rect) { -1 13732 var _grid$numCols; 39964 13733 var x = rect.left; 39965 13734 var y = rect.top; 39966 13735 var startRow = y / gridSize | 0; 39967 13736 var startCol = x / gridSize | 0; 39968 13737 var endRow = (y + rect.height) / gridSize | 0; 39969 13738 var endCol = (x + rect.width) / gridSize | 0; -1 13739 grid.numCols = Math.max((_grid$numCols = grid.numCols) !== null && _grid$numCols !== void 0 ? _grid$numCols : 0, endCol); 39970 13740 for (var row = startRow; row <= endRow; row++) { 39971 13741 grid.cells[row] = grid.cells[row] || []; 39972 13742 for (var col = startCol; col <= endCol; col++) { @@ -39978,86 +13748,6 @@ module.exports = { 39978 13748 } 39979 13749 }); 39980 13750 }39981 -1 function createGrid() {39982 -1 var root = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.body;39983 -1 var rootGrid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {39984 -1 container: null,39985 -1 cells: []39986 -1 };39987 -1 var parentVNode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;39988 -1 if (!parentVNode) {39989 -1 var vNode = get_node_from_tree_default(document.documentElement);39990 -1 if (!vNode) {39991 -1 vNode = new virtual_node_default(document.documentElement);39992 -1 }39993 -1 vNode._stackingOrder = [ 0 ];39994 -1 addNodeToGrid(rootGrid, vNode);39995 -1 if (get_scroll_default(vNode.actualNode)) {39996 -1 var subGrid = {39997 -1 container: vNode,39998 -1 cells: []39999 -1 };40000 -1 vNode._subGrid = subGrid;40001 -1 }40002 -1 }40003 -1 var treeWalker = document.createTreeWalker(root, window.NodeFilter.SHOW_ELEMENT, null, false);40004 -1 var node = parentVNode ? treeWalker.nextNode() : treeWalker.currentNode;40005 -1 while (node) {40006 -1 var _vNode = get_node_from_tree_default(node);40007 -1 if (node.parentElement) {40008 -1 parentVNode = get_node_from_tree_default(node.parentElement);40009 -1 } else if (node.parentNode && get_node_from_tree_default(node.parentNode)) {40010 -1 parentVNode = get_node_from_tree_default(node.parentNode);40011 -1 }40012 -1 if (!_vNode) {40013 -1 _vNode = new axe.VirtualNode(node, parentVNode);40014 -1 }40015 -1 _vNode._stackingOrder = getStackingOrder(_vNode, parentVNode);40016 -1 var scrollRegionParent = findScrollRegionParent(_vNode, parentVNode);40017 -1 var grid = scrollRegionParent ? scrollRegionParent._subGrid : rootGrid;40018 -1 if (get_scroll_default(_vNode.actualNode)) {40019 -1 var _subGrid = {40020 -1 container: _vNode,40021 -1 cells: []40022 -1 };40023 -1 _vNode._subGrid = _subGrid;40024 -1 }40025 -1 var rect = _vNode.boundingClientRect;40026 -1 if (rect.width !== 0 && rect.height !== 0 && is_visible_default(node)) {40027 -1 addNodeToGrid(grid, _vNode);40028 -1 }40029 -1 if (is_shadow_root_default(node)) {40030 -1 createGrid(node.shadowRoot, grid, _vNode);40031 -1 }40032 -1 node = treeWalker.nextNode();40033 -1 }40034 -1 }40035 -1 function getRectStack(grid, rect) {40036 -1 var recursed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;40037 -1 var x = rect.left + rect.width / 2;40038 -1 var y = rect.top + rect.height / 2;40039 -1 var row = y / gridSize | 0;40040 -1 var col = x / gridSize | 0;40041 -1 var stack = grid.cells[row][col].filter(function(gridCellNode) {40042 -1 return gridCellNode.clientRects.find(function(clientRect) {40043 -1 var rectX = clientRect.left;40044 -1 var rectY = clientRect.top;40045 -1 return x <= rectX + clientRect.width && x >= rectX && y <= rectY + clientRect.height && y >= rectY;40046 -1 });40047 -1 });40048 -1 var gridContainer = grid.container;40049 -1 if (gridContainer) {40050 -1 stack = getRectStack(gridContainer._grid, gridContainer.boundingClientRect, true).concat(stack);40051 -1 }40052 -1 if (!recursed) {40053 -1 stack = stack.sort(visuallySort).map(function(vNode) {40054 -1 return vNode.actualNode;40055 -1 }).concat(document.documentElement).filter(function(node, index, array) {40056 -1 return array.indexOf(node) === index;40057 -1 });40058 -1 }40059 -1 return stack;40060 -1 }40061 13751 function getElementStack(node) { 40062 13752 if (!cache_default.get('gridCreated')) { 40063 13753 createGrid(); @@ -40201,7 +13891,7 @@ module.exports = { 40201 13891 ref = idrefs_default(virtualNode.actualNode, 'aria-labelledby'); 40202 13892 candidate = ref.map(function(thing) { 40203 13893 var vNode = get_node_from_tree_default(thing);40204 -1 return vNode ? visible_virtual_default(vNode, true) : '';-1 13894 return vNode ? visible_virtual_default(vNode) : ''; 40205 13895 }).join(' ').trim(); 40206 13896 if (candidate) { 40207 13897 return candidate; @@ -40220,8 +13910,8 @@ module.exports = { 40220 13910 var hiddenTextElms = [ 'HEAD', 'TITLE', 'TEMPLATE', 'SCRIPT', 'STYLE', 'IFRAME', 'OBJECT', 'VIDEO', 'AUDIO', 'NOSCRIPT' ]; 40221 13911 function hasChildTextNodes(elm) { 40222 13912 if (!hiddenTextElms.includes(elm.actualNode.nodeName.toUpperCase())) {40223 -1 return elm.children.some(function(_ref8) {40224 -1 var actualNode = _ref8.actualNode;-1 13913 return elm.children.some(function(_ref10) { -1 13914 var actualNode = _ref10.actualNode; 40225 13915 return actualNode.nodeType === 3 && actualNode.nodeValue.trim(); 40226 13916 }); 40227 13917 } @@ -40285,6 +13975,29 @@ module.exports = { 40285 13975 if (vNode.hasAttr('disabled')) { 40286 13976 return true; 40287 13977 } -1 13978 var parentNode = vNode.parent; -1 13979 var ancestors = []; -1 13980 var fieldsetDisabled = false; -1 13981 while (parentNode && parentNode.shadowId === vNode.shadowId && !fieldsetDisabled) { -1 13982 ancestors.push(parentNode); -1 13983 if (parentNode.props.nodeName === 'legend') { -1 13984 break; -1 13985 } -1 13986 if (parentNode._inDisabledFieldset !== void 0) { -1 13987 fieldsetDisabled = parentNode._inDisabledFieldset; -1 13988 break; -1 13989 } -1 13990 if (parentNode.props.nodeName === 'fieldset' && parentNode.hasAttr('disabled')) { -1 13991 fieldsetDisabled = true; -1 13992 } -1 13993 parentNode = parentNode.parent; -1 13994 } -1 13995 ancestors.forEach(function(ancestor) { -1 13996 return ancestor._inDisabledFieldset = fieldsetDisabled; -1 13997 }); -1 13998 if (fieldsetDisabled) { -1 13999 return true; -1 14000 } 40288 14001 if (vNode.props.nodeName !== 'area') { 40289 14002 if (!vNode.actualNode) { 40290 14003 return false; @@ -40796,9 +14509,8 @@ module.exports = { 40796 14509 }, 40797 14510 combobox: { 40798 14511 type: 'composite',40799 -1 requiredOwned: [ 'listbox', 'tree', 'grid', 'dialog', 'textbox' ],40800 -1 requiredAttrs: [ 'aria-expanded' ],40801 -1 allowedAttrs: [ 'aria-controls', 'aria-autocomplete', 'aria-readonly', 'aria-required', 'aria-activedescendant', 'aria-orientation' ],-1 14512 requiredAttrs: [ 'aria-expanded', 'aria-controls' ], -1 14513 allowedAttrs: [ 'aria-owns', 'aria-autocomplete', 'aria-readonly', 'aria-required', 'aria-activedescendant', 'aria-orientation' ], 40802 14514 superclassRole: [ 'select' ], 40803 14515 accessibleNameRequired: true 40804 14516 }, @@ -40820,6 +14532,11 @@ module.exports = { 40820 14532 allowedAttrs: [ 'aria-expanded' ], 40821 14533 superclassRole: [ 'landmark' ] 40822 14534 }, -1 14535 comment: { -1 14536 type: 'structure', -1 14537 allowedAttrs: [ 'aria-level', 'aria-posinset', 'aria-setsize' ], -1 14538 superclassRole: [ 'article' ] -1 14539 }, 40823 14540 definition: { 40824 14541 type: 'structure', 40825 14542 allowedAttrs: [ 'aria-expanded' ], @@ -40931,7 +14648,7 @@ module.exports = { 40931 14648 }, 40932 14649 listbox: { 40933 14650 type: 'composite',40934 -1 requiredOwned: [ 'option' ],-1 14651 requiredOwned: [ 'group', 'option' ], 40935 14652 allowedAttrs: [ 'aria-multiselectable', 'aria-readonly', 'aria-required', 'aria-activedescendant', 'aria-expanded', 'aria-orientation' ], 40936 14653 superclassRole: [ 'select' ], 40937 14654 accessibleNameRequired: true @@ -41010,6 +14727,11 @@ module.exports = { 41010 14727 accessibleNameRequired: true, 41011 14728 childrenPresentational: true 41012 14729 }, -1 14730 mark: { -1 14731 type: 'structure', -1 14732 superclassRole: [ 'section' ], -1 14733 prohibitedAttrs: [ 'aria-label', 'aria-labelledby' ] -1 14734 }, 41013 14735 navigation: { 41014 14736 type: 'landmark', 41015 14737 allowedAttrs: [ 'aria-expanded' ], @@ -41027,7 +14749,7 @@ module.exports = { 41027 14749 }, 41028 14750 option: { 41029 14751 type: 'widget',41030 -1 requiredContext: [ 'listbox' ],-1 14752 requiredContext: [ 'group', 'listbox' ], 41031 14753 allowedAttrs: [ 'aria-selected', 'aria-checked', 'aria-posinset', 'aria-setsize' ], 41032 14754 superclassRole: [ 'input' ], 41033 14755 accessibleNameRequired: true, @@ -41189,6 +14911,12 @@ module.exports = { 41189 14911 nameFromContent: true, 41190 14912 childrenPresentational: true 41191 14913 }, -1 14914 suggestion: { -1 14915 type: 'structure', -1 14916 requiredOwned: [ 'insertion', 'deletion' ], -1 14917 superclassRole: [ 'section' ], -1 14918 prohibitedAttrs: [ 'aria-label', 'aria-labelledby' ] -1 14919 }, 41192 14920 tab: { 41193 14921 type: 'widget', 41194 14922 requiredContext: [ 'tablist' ], @@ -41316,13 +15044,12 @@ module.exports = { 41316 15044 }, 41317 15045 'doc-biblioentry': { 41318 15046 type: 'listitem',41319 -1 requiredContext: [ 'doc-bibliography' ],41320 15047 allowedAttrs: [ 'aria-expanded', 'aria-level', 'aria-posinset', 'aria-setsize' ],41321 -1 superclassRole: [ 'listitem' ]-1 15048 superclassRole: [ 'listitem' ], -1 15049 deprecated: true 41322 15050 }, 41323 15051 'doc-bibliography': { 41324 15052 type: 'landmark',41325 -1 requiredOwned: [ 'doc-biblioentry' ],41326 15053 allowedAttrs: [ 'aria-expanded' ], 41327 15054 superclassRole: [ 'landmark' ] 41328 15055 }, @@ -41369,13 +15096,12 @@ module.exports = { 41369 15096 }, 41370 15097 'doc-endnote': { 41371 15098 type: 'listitem',41372 -1 requiredContext: [ 'doc-endnotes' ],41373 15099 allowedAttrs: [ 'aria-expanded', 'aria-level', 'aria-posinset', 'aria-setsize' ],41374 -1 superclassRole: [ 'listitem' ]-1 15100 superclassRole: [ 'listitem' ], -1 15101 deprecated: true 41375 15102 }, 41376 15103 'doc-endnotes': { 41377 15104 type: 'landmark',41378 -1 requiredOwned: [ 'doc-endnote' ],41379 15105 allowedAttrs: [ 'aria-expanded' ], 41380 15106 superclassRole: [ 'landmark' ] 41381 15107 }, @@ -41411,7 +15137,6 @@ module.exports = { 41411 15137 }, 41412 15138 'doc-glossary': { 41413 15139 type: 'landmark',41414 -1 requiredOwned: [ 'definition', 'term' ],41415 15140 allowedAttrs: [ 'aria-expanded' ], 41416 15141 superclassRole: [ 'landmark' ] 41417 15142 }, @@ -41532,13 +15257,21 @@ module.exports = { 41532 15257 contentTypes: [ 'phrasing', 'flow' ], 41533 15258 allowedRoles: true 41534 15259 },41535 -1 addres: {-1 15260 address: { 41536 15261 contentTypes: [ 'flow' ], 41537 15262 allowedRoles: true 41538 15263 }, 41539 15264 area: { -1 15265 variant: { -1 15266 href: { -1 15267 matches: '[href]', -1 15268 allowedRoles: false -1 15269 }, -1 15270 default: { -1 15271 allowedRoles: [ 'button', 'link' ] -1 15272 } -1 15273 }, 41540 15274 contentTypes: [ 'phrasing', 'flow' ],41541 -1 allowedRoles: false,41542 15275 namingMethods: [ 'altText' ] 41543 15276 }, 41544 15277 article: { @@ -41565,7 +15298,7 @@ module.exports = { 41565 15298 }, 41566 15299 b: { 41567 15300 contentTypes: [ 'phrasing', 'flow' ],41568 -1 allowedRoles: false-1 15301 allowedRoles: true 41569 15302 }, 41570 15303 base: { 41571 15304 allowedRoles: false, @@ -41778,20 +15511,22 @@ module.exports = { 41778 15511 img: { 41779 15512 variant: { 41780 15513 nonEmptyAlt: {41781 -1 matches: {-1 15514 matches: [ { 41782 15515 attributes: { 41783 15516 alt: '/.+/' 41784 15517 }41785 -1 },41786 -1 allowedRoles: [ 'button', 'checkbox', 'link', 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'option', 'progressbar', 'scrollbar', 'separator', 'slider', 'switch', 'tab', 'treeitem', 'doc-cover' ]-1 15518 }, { -1 15519 hasAccessibleName: true -1 15520 } ], -1 15521 allowedRoles: [ 'button', 'checkbox', 'link', 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'option', 'progressbar', 'radio', 'scrollbar', 'separator', 'slider', 'switch', 'tab', 'treeitem', 'doc-cover' ] 41787 15522 }, 41788 15523 usemap: { 41789 15524 matches: '[usemap]',41790 -1 contentTypes: [ 'interactive', 'embedded', 'phrasing', 'flow' ]-1 15525 contentTypes: [ 'interactive', 'embedded', 'flow' ] 41791 15526 }, 41792 15527 default: { 41793 15528 allowedRoles: [ 'presentation', 'none' ],41794 -1 contentTypes: [ 'embedded', 'phrasing', 'flow' ]-1 15529 contentTypes: [ 'embedded', 'flow' ] 41795 15530 } 41796 15531 }, 41797 15532 namingMethods: [ 'altText' ] @@ -41968,7 +15703,7 @@ module.exports = { 41968 15703 }, 41969 15704 nav: { 41970 15705 contentTypes: [ 'sectioning', 'flow' ],41971 -1 allowedRoles: [ 'doc-index', 'doc-pagelist', 'doc-toc' ],-1 15706 allowedRoles: [ 'doc-index', 'doc-pagelist', 'doc-toc', 'menu', 'menubar', 'none', 'presentation', 'tablist' ], 41972 15707 shadowRoot: true 41973 15708 }, 41974 15709 noscript: { @@ -42027,7 +15762,7 @@ module.exports = { 42027 15762 }, 42028 15763 progress: { 42029 15764 contentTypes: [ 'phrasing', 'flow' ],42030 -1 allowedRoles: true,-1 15765 allowedRoles: false, 42031 15766 implicitAttrs: { 42032 15767 'aria-valuemax': '100', 42033 15768 'aria-valuemin': '0', @@ -42063,7 +15798,7 @@ module.exports = { 42063 15798 }, 42064 15799 section: { 42065 15800 contentTypes: [ 'sectioning', 'flow' ],42066 -1 allowedRoles: [ 'alert', 'alertdialog', 'application', 'banner', 'complementary', 'contentinfo', 'dialog', 'document', 'feed', 'log', 'main', 'marquee', 'navigation', 'none', 'note', 'presentation', 'search', 'status', 'tabpanel', 'doc-abstract', 'doc-acknowledgments', 'doc-afterword', 'doc-appendix', 'doc-bibliography', 'doc-chapter', 'doc-colophon', 'doc-conclusion', 'doc-credit', 'doc-credits', 'doc-dedication', 'doc-endnotes', 'doc-epigraph', 'doc-epilogue', 'doc-errata', 'doc-example', 'doc-foreword', 'doc-glossary', 'doc-index', 'doc-introduction', 'doc-notice', 'doc-pagelist', 'doc-part', 'doc-preface', 'doc-prologue', 'doc-pullquote', 'doc-qna', 'doc-toc' ],-1 15801 allowedRoles: [ 'alert', 'alertdialog', 'application', 'banner', 'complementary', 'contentinfo', 'dialog', 'document', 'feed', 'group', 'log', 'main', 'marquee', 'navigation', 'none', 'note', 'presentation', 'search', 'status', 'tabpanel', 'doc-abstract', 'doc-acknowledgments', 'doc-afterword', 'doc-appendix', 'doc-bibliography', 'doc-chapter', 'doc-colophon', 'doc-conclusion', 'doc-credit', 'doc-credits', 'doc-dedication', 'doc-endnotes', 'doc-epigraph', 'doc-epilogue', 'doc-errata', 'doc-example', 'doc-foreword', 'doc-glossary', 'doc-index', 'doc-introduction', 'doc-notice', 'doc-pagelist', 'doc-part', 'doc-preface', 'doc-prologue', 'doc-pullquote', 'doc-qna', 'doc-toc' ], 42067 15802 shadowRoot: true 42068 15803 }, 42069 15804 select: { @@ -42115,7 +15850,7 @@ module.exports = { 42115 15850 }, 42116 15851 svg: { 42117 15852 contentTypes: [ 'embedded', 'phrasing', 'flow' ],42118 -1 allowedRoles: [ 'application', 'document', 'img' ],-1 15853 allowedRoles: true, 42119 15854 chromiumRole: 'SVGRoot', 42120 15855 namingMethods: [ 'svgTitleText' ] 42121 15856 }, @@ -42207,7 +15942,7 @@ module.exports = { 42207 15942 }, 42208 15943 wbr: { 42209 15944 contentTypes: [ 'phrasing', 'flow' ],42210 -1 allowedRoles: true-1 15945 allowedRoles: [ 'presentation', 'none' ] 42211 15946 } 42212 15947 }; 42213 15948 var html_elms_default = htmlElms; @@ -42399,8 +16134,8 @@ module.exports = { 42399 16134 } 42400 16135 return parseFloat(value); 42401 16136 }42402 -1 function hslToRgb(_ref9) {42403 -1 var _ref10 = _slicedToArray(_ref9, 4), hue = _ref10[0], saturation = _ref10[1], lightness = _ref10[2], alpha = _ref10[3];-1 16137 function hslToRgb(_ref11) { -1 16138 var _ref12 = _slicedToArray(_ref11, 4), hue = _ref12[0], saturation = _ref12[1], lightness = _ref12[2], alpha = _ref12[3]; 42404 16139 saturation /= 255; 42405 16140 lightness /= 255; 42406 16141 var high = (1 - Math.abs(2 * lightness - 1)) * saturation; @@ -42420,8 +16155,8 @@ module.exports = { 42420 16155 } else { 42421 16156 colors = [ high, 0, low ]; 42422 16157 }42423 -1 return colors.map(function(color10) {42424 -1 return Math.round((color10 + base) * 255);-1 16158 return colors.map(function(color11) { -1 16159 return Math.round((color11 + base) * 255); 42425 16160 }).concat(alpha); 42426 16161 } 42427 16162 function Color(red, green, blue, alpha) { @@ -42439,7 +16174,7 @@ module.exports = { 42439 16174 var colorFnRegex = /^((?:rgb|hsl)a?)\s*\(([^\)]*)\)/i; 42440 16175 this.parseString = function parseString(colorString) { 42441 16176 if (standards_default.cssColors[colorString] || colorString === 'transparent') {42442 -1 var _ref11 = standards_default.cssColors[colorString] || [ 0, 0, 0 ], _ref12 = _slicedToArray(_ref11, 3), red2 = _ref12[0], green2 = _ref12[1], blue2 = _ref12[2];-1 16177 var _ref13 = standards_default.cssColors[colorString] || [ 0, 0, 0 ], _ref14 = _slicedToArray(_ref13, 3), red2 = _ref14[0], green2 = _ref14[1], blue2 = _ref14[2]; 42443 16178 this.red = red2; 42444 16179 this.green = green2; 42445 16180 this.blue = blue2; @@ -42489,7 +16224,7 @@ module.exports = { 42489 16224 } 42490 16225 }; 42491 16226 this.parseColorFnString = function parseColorFnString(colorString) {42492 -1 var _ref13 = colorString.match(colorFnRegex) || [], _ref14 = _slicedToArray(_ref13, 3), colorFunc = _ref14[1], colorValStr = _ref14[2];-1 16227 var _ref15 = colorString.match(colorFnRegex) || [], _ref16 = _slicedToArray(_ref15, 3), colorFunc = _ref16[1], colorValStr = _ref16[2]; 42493 16228 if (!colorFunc || !colorValStr) { 42494 16229 return; 42495 16230 } @@ -42535,16 +16270,21 @@ module.exports = { 42535 16270 return element_has_image_default(node, style) || get_own_background_color_default(style).alpha === 1; 42536 16271 } 42537 16272 var is_opaque_default = isOpaque;42538 -1 var isInternalLinkRegex = /^\/?#[^/!]/;42539 -1 function isSkipLink(element) {42540 -1 if (!isInternalLinkRegex.test(element.getAttribute('href'))) {-1 16273 function _isSkipLink(element) { -1 16274 if (!element.href) { 42541 16275 return false; 42542 16276 } 42543 16277 var firstPageLink; 42544 16278 if (typeof cache_default.get('firstPageLink') !== 'undefined') { 42545 16279 firstPageLink = cache_default.get('firstPageLink'); 42546 16280 } else {42547 -1 firstPageLink = query_selector_all_default(axe._tree, 'a:not([href^="#"]):not([href^="/#"]):not([href^="javascript"])')[0];-1 16281 if (!window.location.origin) { -1 16282 firstPageLink = query_selector_all_default(axe._tree, 'a:not([href^="#"]):not([href^="/#"]):not([href^="javascript:"])')[0]; -1 16283 } else { -1 16284 firstPageLink = query_selector_all_default(axe._tree, 'a[href]:not([href^="javascript:"])').find(function(link) { -1 16285 return !_isCurrentPageLink(link.actualNode); -1 16286 }); -1 16287 } 42548 16288 cache_default.set('firstPageLink', firstPageLink || null); 42549 16289 } 42550 16290 if (!firstPageLink) { @@ -42552,7 +16292,6 @@ module.exports = { 42552 16292 } 42553 16293 return element.compareDocumentPosition(firstPageLink.actualNode) === element.DOCUMENT_POSITION_FOLLOWING; 42554 16294 }42555 -1 var is_skip_link_default = isSkipLink;42556 16295 function reduceToElementsBelowFloating(elements, targetNode) { 42557 16296 var floatingPositions = [ 'fixed', 'sticky' ]; 42558 16297 var finalElements = []; @@ -42572,58 +16311,52 @@ module.exports = { 42572 16311 return finalElements; 42573 16312 } 42574 16313 var reduce_to_elements_below_floating_default = reduceToElementsBelowFloating; -1 16314 function _visuallyContains(node, parent) { -1 16315 var parentScrollAncestor = getScrollAncestor(parent); -1 16316 do { -1 16317 var nextScrollAncestor = getScrollAncestor(node); -1 16318 if (nextScrollAncestor === parentScrollAncestor || nextScrollAncestor === parent) { -1 16319 return contains2(node, parent); -1 16320 } -1 16321 node = nextScrollAncestor; -1 16322 } while (node); -1 16323 return false; -1 16324 } 42575 16325 function getScrollAncestor(node) { 42576 16326 var vNode = get_node_from_tree_default(node); 42577 16327 var ancestor = vNode.parent; 42578 16328 while (ancestor) {42579 -1 if (get_scroll_default(ancestor.actualNode)) {-1 16329 if (_getScroll(ancestor.actualNode)) { 42580 16330 return ancestor.actualNode; 42581 16331 } 42582 16332 ancestor = ancestor.parent; 42583 16333 } 42584 16334 } 42585 16335 function contains2(node, parent) {42586 -1 var rectBound = node.getBoundingClientRect();42587 -1 var margin = .01;42588 -1 var rect = {42589 -1 top: rectBound.top + margin,42590 -1 bottom: rectBound.bottom - margin,42591 -1 left: rectBound.left + margin,42592 -1 right: rectBound.right - margin42593 -1 };42594 -1 var parentRect = parent.getBoundingClientRect();42595 -1 var parentTop = parentRect.top;42596 -1 var parentLeft = parentRect.left;42597 -1 var parentScrollArea = {42598 -1 top: parentTop - parent.scrollTop,42599 -1 bottom: parentTop - parent.scrollTop + parent.scrollHeight,42600 -1 left: parentLeft - parent.scrollLeft,42601 -1 right: parentLeft - parent.scrollLeft + parent.scrollWidth42602 -1 };42603 16336 var style = window.getComputedStyle(parent); -1 16337 var overflow = style.getPropertyValue('overflow'); 42604 16338 if (style.getPropertyValue('display') === 'inline') { 42605 16339 return true; 42606 16340 }42607 -1 if (rect.left < parentScrollArea.left && rect.left < parentRect.left || rect.top < parentScrollArea.top && rect.top < parentRect.top || rect.right > parentScrollArea.right && rect.right > parentRect.right || rect.bottom > parentScrollArea.bottom && rect.bottom > parentRect.bottom) {42608 -1 return false;-1 16341 var clientRects = Array.from(node.getClientRects()); -1 16342 var boundingRect = parent.getBoundingClientRect(); -1 16343 var rect = { -1 16344 left: boundingRect.left, -1 16345 top: boundingRect.top, -1 16346 width: boundingRect.width, -1 16347 height: boundingRect.height -1 16348 }; -1 16349 if ([ 'scroll', 'auto' ].includes(overflow) || parent instanceof window.HTMLHtmlElement) { -1 16350 rect.width = parent.scrollWidth; -1 16351 rect.height = parent.scrollHeight; 42609 16352 }42610 -1 if (rect.right > parentRect.right || rect.bottom > parentRect.bottom) {42611 -1 return style.overflow === 'scroll' || style.overflow === 'auto' || style.overflow === 'hidden' || parent instanceof window.HTMLBodyElement || parent instanceof window.HTMLHtmlElement;-1 16353 if (clientRects.length === 1 && overflow === 'hidden' && style.getPropertyValue('white-space') === 'nowrap') { -1 16354 clientRects[0] = rect; 42612 16355 }42613 -1 return true;42614 -1 }42615 -1 function visuallyContains(node, parent) {42616 -1 var parentScrollAncestor = getScrollAncestor(parent);42617 -1 do {42618 -1 var nextScrollAncestor = getScrollAncestor(node);42619 -1 if (nextScrollAncestor === parentScrollAncestor || nextScrollAncestor === parent) {42620 -1 return contains2(node, parent);42621 -1 }42622 -1 node = nextScrollAncestor;42623 -1 } while (node);42624 -1 return false;-1 16356 return clientRects.some(function(clientRect) { -1 16357 return !(Math.ceil(clientRect.left) < Math.floor(rect.left) || Math.ceil(clientRect.top) < Math.floor(rect.top) || Math.floor(clientRect.left + clientRect.width) > Math.ceil(rect.left + rect.width) || Math.floor(clientRect.top + clientRect.height) > Math.ceil(rect.top + rect.height)); -1 16358 }); 42625 16359 }42626 -1 var visually_contains_default = visuallyContains;42627 16360 function shadowElementsFromPoint(nodeX, nodeY) { 42628 16361 var root = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : document; 42629 16362 var i = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; @@ -42636,7 +16369,7 @@ module.exports = { 42636 16369 if (is_shadow_root_default(elm)) { 42637 16370 var shadowStack = shadowElementsFromPoint(nodeX, nodeY, elm.shadowRoot, i + 1); 42638 16371 stack = stack.concat(shadowStack);42639 -1 if (stack.length && visually_contains_default(stack[0], elm)) {-1 16372 if (stack.length && _visuallyContains(stack[0], elm)) { 42640 16373 stack.push(elm); 42641 16374 } 42642 16375 } else { @@ -42777,16 +16510,20 @@ module.exports = { 42777 16510 _createClass(VirtualNode, [ { 42778 16511 key: 'props', 42779 16512 get: function get() {42780 -1 var _this$actualNode = this.actualNode, nodeType = _this$actualNode.nodeType, nodeName2 = _this$actualNode.nodeName, id = _this$actualNode.id, multiple = _this$actualNode.multiple, nodeValue = _this$actualNode.nodeValue, value = _this$actualNode.value;42781 -1 return {42782 -1 nodeType: nodeType,42783 -1 nodeName: this._isXHTML ? nodeName2 : nodeName2.toLowerCase(),42784 -1 id: id,42785 -1 type: this._type,42786 -1 multiple: multiple,42787 -1 nodeValue: nodeValue,42788 -1 value: value42789 -1 };-1 16513 if (!this._cache.hasOwnProperty('props')) { -1 16514 var _this$actualNode = this.actualNode, nodeType = _this$actualNode.nodeType, nodeName2 = _this$actualNode.nodeName, id = _this$actualNode.id, multiple = _this$actualNode.multiple, nodeValue = _this$actualNode.nodeValue, value = _this$actualNode.value, selected = _this$actualNode.selected; -1 16515 this._cache.props = { -1 16516 nodeType: nodeType, -1 16517 nodeName: this._isXHTML ? nodeName2 : nodeName2.toLowerCase(), -1 16518 id: id, -1 16519 type: this._type, -1 16520 multiple: multiple, -1 16521 nodeValue: nodeValue, -1 16522 value: value, -1 16523 selected: selected -1 16524 }; -1 16525 } -1 16526 return this._cache.props; 42790 16527 } 42791 16528 }, { 42792 16529 key: 'attr', @@ -42870,6 +16607,7 @@ module.exports = { 42870 16607 return VirtualNode; 42871 16608 }(abstract_virtual_node_default); 42872 16609 var virtual_node_default = VirtualNode; -1 16610 var hasShadowRoot; 42873 16611 function getSlotChildren(node) { 42874 16612 var retVal = []; 42875 16613 node = node.firstChild; @@ -42893,6 +16631,7 @@ module.exports = { 42893 16631 } 42894 16632 nodeName2 = node.nodeName.toLowerCase(); 42895 16633 if (is_shadow_root_default(node)) { -1 16634 hasShadowRoot = true; 42896 16635 retVal = new virtual_node_default(node, parent, shadowId); 42897 16636 shadowId = 'a' + Math.random().toString().substring(2); 42898 16637 realArray = Array.from(node.shadowRoot.childNodes); @@ -42941,8 +16680,11 @@ module.exports = { 42941 16680 function getFlattenedTree() { 42942 16681 var node = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.documentElement; 42943 16682 var shadowId = arguments.length > 1 ? arguments[1] : undefined; -1 16683 hasShadowRoot = false; 42944 16684 cache_default.set('nodeMap', new WeakMap());42945 -1 return flattenTree(node, shadowId, null);-1 16685 var tree = flattenTree(node, shadowId, null); -1 16686 tree[0]._hasShadowRoot = hasShadowRoot; -1 16687 return tree; 42946 16688 } 42947 16689 var get_flattened_tree_default = getFlattenedTree; 42948 16690 function getBaseLang(lang) { @@ -42971,34 +16713,16 @@ module.exports = { 42971 16713 }).join('\n\n'); 42972 16714 } 42973 16715 var failure_summary_default = failureSummary;42974 -1 function getEnvironmentData() {42975 -1 var win = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;42976 -1 var _win$screen = win.screen, screen = _win$screen === void 0 ? {} : _win$screen, _win$navigator = win.navigator, navigator = _win$navigator === void 0 ? {} : _win$navigator, _win$location = win.location, location = _win$location === void 0 ? {} : _win$location, innerHeight = win.innerHeight, innerWidth = win.innerWidth;42977 -1 var orientation = screen.msOrientation || screen.orientation || screen.mozOrientation || {};42978 -1 return {42979 -1 testEngine: {42980 -1 name: 'axe-core',42981 -1 version: axe.version42982 -1 },42983 -1 testRunner: {42984 -1 name: axe._audit.brand42985 -1 },42986 -1 testEnvironment: {42987 -1 userAgent: navigator.userAgent,42988 -1 windowWidth: innerWidth,42989 -1 windowHeight: innerHeight,42990 -1 orientationAngle: orientation.angle,42991 -1 orientationType: orientation.type42992 -1 },42993 -1 timestamp: new Date().toISOString(),42994 -1 url: location.href42995 -1 };42996 -1 }42997 -1 var get_environment_data_default = getEnvironmentData;42998 16716 function incompleteFallbackMessage() {42999 -1 return typeof axe._audit.data.incompleteFallbackMessage === 'function' ? axe._audit.data.incompleteFallbackMessage() : axe._audit.data.incompleteFallbackMessage;-1 16717 var incompleteFallbackMessage2 = axe._audit.data.incompleteFallbackMessage; -1 16718 if (typeof incompleteFallbackMessage2 === 'function') { -1 16719 incompleteFallbackMessage2 = incompleteFallbackMessage2(); -1 16720 } -1 16721 if (typeof incompleteFallbackMessage2 !== 'string') { -1 16722 return ''; -1 16723 } -1 16724 return incompleteFallbackMessage2; 43000 16725 }43001 -1 var incomplete_fallback_msg_default = incompleteFallbackMessage;43002 16726 function normalizeRelatedNodes(node, options) { 43003 16727 [ 'any', 'all', 'none' ].forEach(function(type) { 43004 16728 if (!Array.isArray(node[type])) { @@ -43078,8 +16802,7 @@ module.exports = { 43078 16802 axe._thisWillBeDeletedDoNotUse = axe._thisWillBeDeletedDoNotUse || {}; 43079 16803 axe._thisWillBeDeletedDoNotUse.helpers = { 43080 16804 failureSummary: failure_summary_default,43081 -1 getEnvironmentData: get_environment_data_default,43082 -1 incompleteFallbackMessage: incomplete_fallback_msg_default,-1 16805 incompleteFallbackMessage: incompleteFallbackMessage, 43083 16806 processAggregate: process_aggregate_default 43084 16807 }; 43085 16808 var dataRegex = /\$\{\s?data\s?\}/g; @@ -43115,7 +16838,7 @@ module.exports = { 43115 16838 var _str = message[data2]; 43116 16839 return substitute(_str, data2); 43117 16840 }43118 -1 var str = message['default'] || incomplete_fallback_msg_default();-1 16841 var str = message['default'] || incompleteFallbackMessage(); 43119 16842 if (data2 && data2.messageKey && message[data2.messageKey]) { 43120 16843 str = message[data2.messageKey]; 43121 16844 } @@ -43161,6 +16884,250 @@ module.exports = { 43161 16884 }; 43162 16885 } 43163 16886 var get_check_option_default = getCheckOption; -1 16887 function _getEnvironmentData() { -1 16888 var _win$location; -1 16889 var metadata = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; -1 16890 var win = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window; -1 16891 if (metadata && _typeof(metadata) === 'object') { -1 16892 return metadata; -1 16893 } else if (_typeof(win) !== 'object') { -1 16894 return {}; -1 16895 } -1 16896 return { -1 16897 testEngine: { -1 16898 name: 'axe-core', -1 16899 version: axe.version -1 16900 }, -1 16901 testRunner: { -1 16902 name: axe._audit.brand -1 16903 }, -1 16904 testEnvironment: getTestEnvironment(win), -1 16905 timestamp: new Date().toISOString(), -1 16906 url: (_win$location = win.location) === null || _win$location === void 0 ? void 0 : _win$location.href -1 16907 }; -1 16908 } -1 16909 function getTestEnvironment(win) { -1 16910 if (!win.navigator || _typeof(win.navigator) !== 'object') { -1 16911 return {}; -1 16912 } -1 16913 var navigator = win.navigator, innerHeight = win.innerHeight, innerWidth = win.innerWidth; -1 16914 var _ref17 = getOrientation(win) || {}, angle = _ref17.angle, type = _ref17.type; -1 16915 return { -1 16916 userAgent: navigator.userAgent, -1 16917 windowWidth: innerWidth, -1 16918 windowHeight: innerHeight, -1 16919 orientationAngle: angle, -1 16920 orientationType: type -1 16921 }; -1 16922 } -1 16923 function getOrientation(_ref18) { -1 16924 var screen = _ref18.screen; -1 16925 return screen.orientation || screen.msOrientation || screen.mozOrientation; -1 16926 } -1 16927 function createFrameContext(frame, _ref19) { -1 16928 var focusable = _ref19.focusable, page = _ref19.page; -1 16929 return { -1 16930 node: frame, -1 16931 include: [], -1 16932 exclude: [], -1 16933 initiator: false, -1 16934 focusable: focusable && frameFocusable(frame), -1 16935 size: getBoundingSize(frame), -1 16936 page: page -1 16937 }; -1 16938 } -1 16939 function frameFocusable(frame) { -1 16940 var tabIndex = frame.getAttribute('tabindex'); -1 16941 if (!tabIndex) { -1 16942 return true; -1 16943 } -1 16944 var _int = parseInt(tabIndex, 10); -1 16945 return isNaN(_int) || _int >= 0; -1 16946 } -1 16947 function getBoundingSize(domNode) { -1 16948 var width = parseInt(domNode.getAttribute('width'), 10); -1 16949 var height = parseInt(domNode.getAttribute('height'), 10); -1 16950 if (isNaN(width) || isNaN(height)) { -1 16951 var rect = domNode.getBoundingClientRect(); -1 16952 width = isNaN(width) ? rect.width : width; -1 16953 height = isNaN(height) ? rect.height : height; -1 16954 } -1 16955 return { -1 16956 width: width, -1 16957 height: height -1 16958 }; -1 16959 } -1 16960 function pushUniqueFrame(context5, frame) { -1 16961 if (is_hidden_default(frame) || find_by_default(context5.frames, 'node', frame)) { -1 16962 return; -1 16963 } -1 16964 context5.frames.push(createFrameContext(frame, context5)); -1 16965 } -1 16966 function isPageContext(_ref20) { -1 16967 var include = _ref20.include; -1 16968 return include.length === 1 && include[0].actualNode === document.documentElement; -1 16969 } -1 16970 function pushUniqueFrameSelector(context5, type, selectorArray) { -1 16971 context5.frames = context5.frames || []; -1 16972 var frameSelector = selectorArray.shift(); -1 16973 var frames = document.querySelectorAll(frameSelector); -1 16974 Array.from(frames).forEach(function(frame) { -1 16975 context5.frames.forEach(function(contextFrame) { -1 16976 if (contextFrame.node === frame) { -1 16977 contextFrame[type].push(selectorArray); -1 16978 } -1 16979 }); -1 16980 if (!context5.frames.find(function(result) { -1 16981 return result.node === frame; -1 16982 })) { -1 16983 var result = createFrameContext(frame, context5); -1 16984 if (selectorArray) { -1 16985 result[type].push(selectorArray); -1 16986 } -1 16987 context5.frames.push(result); -1 16988 } -1 16989 }); -1 16990 } -1 16991 function normalizeContext(context5) { -1 16992 if (context5 && _typeof(context5) === 'object' || context5 instanceof window.NodeList) { -1 16993 if (context5 instanceof window.Node) { -1 16994 return { -1 16995 include: [ context5 ], -1 16996 exclude: [] -1 16997 }; -1 16998 } -1 16999 if (context5.hasOwnProperty('include') || context5.hasOwnProperty('exclude')) { -1 17000 return { -1 17001 include: context5.include && +context5.include.length ? context5.include : [ document ], -1 17002 exclude: context5.exclude || [] -1 17003 }; -1 17004 } -1 17005 if (context5.length === +context5.length) { -1 17006 return { -1 17007 include: context5, -1 17008 exclude: [] -1 17009 }; -1 17010 } -1 17011 } -1 17012 if (typeof context5 === 'string') { -1 17013 return { -1 17014 include: [ context5 ], -1 17015 exclude: [] -1 17016 }; -1 17017 } -1 17018 return { -1 17019 include: [ document ], -1 17020 exclude: [] -1 17021 }; -1 17022 } -1 17023 function parseSelectorArray(context5, type) { -1 17024 var item, result = [], nodeList; -1 17025 for (var i = 0, l = context5[type].length; i < l; i++) { -1 17026 item = context5[type][i]; -1 17027 if (typeof item === 'string') { -1 17028 nodeList = Array.from(document.querySelectorAll(item)); -1 17029 result = result.concat(nodeList.map(function(node) { -1 17030 return get_node_from_tree_default(node); -1 17031 })); -1 17032 break; -1 17033 } else if (item && item.length && !(item instanceof window.Node)) { -1 17034 if (item.length > 1) { -1 17035 pushUniqueFrameSelector(context5, type, item); -1 17036 } else { -1 17037 nodeList = Array.from(document.querySelectorAll(item[0])); -1 17038 result = result.concat(nodeList.map(function(node) { -1 17039 return get_node_from_tree_default(node); -1 17040 })); -1 17041 } -1 17042 } else if (item instanceof window.Node) { -1 17043 if (item.documentElement instanceof window.Node) { -1 17044 result.push(context5.flatTree[0]); -1 17045 } else { -1 17046 result.push(get_node_from_tree_default(item)); -1 17047 } -1 17048 } -1 17049 } -1 17050 return result.filter(function(r) { -1 17051 return r; -1 17052 }); -1 17053 } -1 17054 function validateContext(context5) { -1 17055 if (context5.include.length === 0) { -1 17056 if (context5.frames.length === 0) { -1 17057 var env = _respondable.isInFrame() ? 'frame' : 'page'; -1 17058 return new Error('No elements found for include in ' + env + ' Context'); -1 17059 } -1 17060 context5.frames.forEach(function(frame, i) { -1 17061 if (frame.include.length === 0) { -1 17062 return new Error('No elements found for include in Context of frame ' + i); -1 17063 } -1 17064 }); -1 17065 } -1 17066 } -1 17067 function getRootNode2(_ref21) { -1 17068 var include = _ref21.include, exclude = _ref21.exclude; -1 17069 var selectors = Array.from(include).concat(Array.from(exclude)); -1 17070 for (var i = 0; i < selectors.length; ++i) { -1 17071 var item = selectors[i]; -1 17072 if (item instanceof window.Element) { -1 17073 return item.ownerDocument.documentElement; -1 17074 } -1 17075 if (item instanceof window.Document) { -1 17076 return item.documentElement; -1 17077 } -1 17078 } -1 17079 return document.documentElement; -1 17080 } -1 17081 function Context(spec, flatTree) { -1 17082 var _spec, _spec2, _spec3, _spec4, _this2 = this; -1 17083 spec = clone_default(spec); -1 17084 this.frames = []; -1 17085 this.page = typeof ((_spec = spec) === null || _spec === void 0 ? void 0 : _spec.page) === 'boolean' ? spec.page : void 0; -1 17086 this.initiator = typeof ((_spec2 = spec) === null || _spec2 === void 0 ? void 0 : _spec2.initiator) === 'boolean' ? spec.initiator : true; -1 17087 this.focusable = typeof ((_spec3 = spec) === null || _spec3 === void 0 ? void 0 : _spec3.focusable) === 'boolean' ? spec.focusable : true; -1 17088 this.size = _typeof((_spec4 = spec) === null || _spec4 === void 0 ? void 0 : _spec4.size) === 'object' ? spec.size : {}; -1 17089 spec = normalizeContext(spec); -1 17090 this.flatTree = flatTree !== null && flatTree !== void 0 ? flatTree : get_flattened_tree_default(getRootNode2(spec)); -1 17091 this.exclude = spec.exclude; -1 17092 this.include = spec.include; -1 17093 this.include = parseSelectorArray(this, 'include'); -1 17094 this.exclude = parseSelectorArray(this, 'exclude'); -1 17095 select_default('frame, iframe', this).forEach(function(frame) { -1 17096 if (is_node_in_context_default(frame, _this2)) { -1 17097 pushUniqueFrame(_this2, frame.actualNode); -1 17098 } -1 17099 }); -1 17100 if (typeof this.page === 'undefined') { -1 17101 this.page = isPageContext(this); -1 17102 this.frames.forEach(function(frame) { -1 17103 frame.page = _this2.page; -1 17104 }); -1 17105 } -1 17106 var err2 = validateContext(this); -1 17107 if (err2 instanceof Error) { -1 17108 throw err2; -1 17109 } -1 17110 if (!Array.isArray(this.include)) { -1 17111 this.include = Array.from(this.include); -1 17112 } -1 17113 this.include.sort(node_sorter_default); -1 17114 } -1 17115 function _getFrameContexts(context5) { -1 17116 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; -1 17117 if (options.iframes === false) { -1 17118 return []; -1 17119 } -1 17120 var _Context = new Context(context5), frames = _Context.frames; -1 17121 return frames.map(function(_ref22) { -1 17122 var node = _ref22.node, frameContext = _objectWithoutProperties(_ref22, _excluded2); -1 17123 frameContext.initiator = false; -1 17124 var frameSelector = _getAncestry(node); -1 17125 return { -1 17126 frameSelector: frameSelector, -1 17127 frameContext: frameContext -1 17128 }; -1 17129 }); -1 17130 } 43164 17131 function getRule(ruleId) { 43165 17132 var rule3 = axe._audit.rules.find(function(rule4) { 43166 17133 return rule4.id === ruleId; @@ -43171,7 +17138,7 @@ module.exports = { 43171 17138 return rule3; 43172 17139 } 43173 17140 var get_rule_default = getRule;43174 -1 function getScroll(elm) {-1 17141 function _getScroll(elm) { 43175 17142 var buffer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; 43176 17143 var overflowX = elm.scrollWidth > elm.clientWidth + buffer; 43177 17144 var overflowY = elm.scrollHeight > elm.clientHeight + buffer; @@ -43179,10 +17146,8 @@ module.exports = { 43179 17146 return; 43180 17147 } 43181 17148 var style = window.getComputedStyle(elm);43182 -1 var overflowXStyle = style.getPropertyValue('overflow-x');43183 -1 var overflowYStyle = style.getPropertyValue('overflow-y');43184 -1 var scrollableX = overflowXStyle !== 'visible' && overflowXStyle !== 'hidden';43185 -1 var scrollableY = overflowYStyle !== 'visible' && overflowYStyle !== 'hidden';-1 17149 var scrollableX = isScrollable(style, 'overflow-x'); -1 17150 var scrollableY = isScrollable(style, 'overflow-y'); 43186 17151 if (overflowX && scrollableX || overflowY && scrollableY) { 43187 17152 return { 43188 17153 elm: elm, @@ -43191,10 +17156,13 @@ module.exports = { 43191 17156 }; 43192 17157 } 43193 17158 }43194 -1 var get_scroll_default = getScroll;-1 17159 function isScrollable(style, prop) { -1 17160 var overflowProp = style.getPropertyValue(prop); -1 17161 return [ 'scroll', 'auto' ].includes(overflowProp); -1 17162 } 43195 17163 function getElmScrollRecursive(root) { 43196 17164 return Array.from(root.children || root.childNodes || []).reduce(function(scrolls, elm) {43197 -1 var scroll = get_scroll_default(elm);-1 17165 var scroll = _getScroll(elm); 43198 17166 if (scroll) { 43199 17167 scrolls.push(scroll); 43200 17168 } @@ -43291,35 +17259,54 @@ module.exports = { 43291 17259 return hidden; 43292 17260 } 43293 17261 var is_hidden_default = isHidden;43294 -1 var htmlTags = [ 'a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'math', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rb', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'script', 'section', 'select', 'slot', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'svg', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr' ];43295 17262 function isHtmlElement(node) { -1 17263 var _node$props$nodeName, _node$props; -1 17264 var nodeName2 = (_node$props$nodeName = (_node$props = node.props) === null || _node$props === void 0 ? void 0 : _node$props.nodeName) !== null && _node$props$nodeName !== void 0 ? _node$props$nodeName : node.nodeName.toLowerCase(); 43296 17265 if (node.namespaceURI === 'http://www.w3.org/2000/svg') { 43297 17266 return false; 43298 17267 }43299 -1 return htmlTags.includes(node.nodeName.toLowerCase());-1 17268 return !!standards_default.htmlElms[nodeName2]; 43300 17269 } 43301 17270 var is_html_element_default = isHtmlElement; 43302 17271 function getDeepest(collection) { 43303 17272 return collection.sort(function(a, b) {43304 -1 if (contains_default(a, b)) {-1 17273 if (_contains(a, b)) { 43305 17274 return 1; 43306 17275 } 43307 17276 return -1; 43308 17277 })[0]; 43309 17278 }43310 -1 function isNodeInContext(node, context3) {43311 -1 var include = context3.include && getDeepest(context3.include.filter(function(candidate) {43312 -1 return contains_default(candidate, node);-1 17279 function isNodeInContext(node, context5) { -1 17280 var include = context5.include && getDeepest(context5.include.filter(function(candidate) { -1 17281 return _contains(candidate, node); 43313 17282 }));43314 -1 var exclude = context3.exclude && getDeepest(context3.exclude.filter(function(candidate) {43315 -1 return contains_default(candidate, node);-1 17283 var exclude = context5.exclude && getDeepest(context5.exclude.filter(function(candidate) { -1 17284 return _contains(candidate, node); 43316 17285 }));43317 -1 if (!exclude && include || exclude && contains_default(exclude, include)) {-1 17286 if (!exclude && include || exclude && _contains(exclude, include)) { 43318 17287 return true; 43319 17288 } 43320 17289 return false; 43321 17290 } 43322 17291 var is_node_in_context_default = isNodeInContext; -1 17292 function matchAncestry(ancestryA, ancestryB) { -1 17293 if (ancestryA.length !== ancestryB.length) { -1 17294 return false; -1 17295 } -1 17296 return ancestryA.every(function(selectorA, index) { -1 17297 var selectorB = ancestryB[index]; -1 17298 if (!Array.isArray(selectorA)) { -1 17299 return selectorA === selectorB; -1 17300 } -1 17301 if (selectorA.length !== selectorB.length) { -1 17302 return false; -1 17303 } -1 17304 return selectorA.every(function(str, index2) { -1 17305 return selectorB[index2] === str; -1 17306 }); -1 17307 }); -1 17308 } -1 17309 var match_ancestry_default = matchAncestry; 43323 17310 var memoizee = __toModule(require_memoizee()); 43324 17311 axe._memoizedFns = []; 43325 17312 function memoizeImplementation(fn) { @@ -43754,29 +17741,31 @@ module.exports = { 43754 17741 }); 43755 17742 } 43756 17743 var unique_array_default = uniqueArray;43757 -1 function createLocalVariables(vNodes, anyLevel, thisLevel, parentShadowId) {43758 -1 var retVal = {43759 -1 vNodes: vNodes.slice(),43760 -1 anyLevel: anyLevel,43761 -1 thisLevel: thisLevel,43762 -1 parentShadowId: parentShadowId43763 -1 };43764 -1 retVal.vNodes.reverse();-1 17744 function createLocalVariables(vNodes, anyLevel, thisLevel, parentShadowId, recycledLocalVariable) { -1 17745 var retVal = recycledLocalVariable || {}; -1 17746 retVal.vNodes = vNodes; -1 17747 retVal.vNodesIndex = 0; -1 17748 retVal.anyLevel = anyLevel; -1 17749 retVal.thisLevel = thisLevel; -1 17750 retVal.parentShadowId = parentShadowId; 43765 17751 return retVal; 43766 17752 } -1 17753 var recycledLocalVariables = []; 43767 17754 function matchExpressions(domTree, expressions, filter) { 43768 17755 var stack = []; 43769 17756 var vNodes = Array.isArray(domTree) ? domTree : [ domTree ];43770 -1 var currentLevel = createLocalVariables(vNodes, expressions, [], domTree[0].shadowId);-1 17757 var currentLevel = createLocalVariables(vNodes, expressions, null, domTree[0].shadowId, recycledLocalVariables.pop()); 43771 17758 var result = [];43772 -1 while (currentLevel.vNodes.length) {43773 -1 var vNode = currentLevel.vNodes.pop();43774 -1 var childOnly = [];43775 -1 var childAny = [];43776 -1 var combined = currentLevel.anyLevel.slice().concat(currentLevel.thisLevel);-1 17759 while (currentLevel.vNodesIndex < currentLevel.vNodes.length) { -1 17760 var _currentLevel$anyLeve, _currentLevel$thisLev; -1 17761 var vNode = currentLevel.vNodes[currentLevel.vNodesIndex++]; -1 17762 var childOnly = null; -1 17763 var childAny = null; -1 17764 var combinedLength = (((_currentLevel$anyLeve = currentLevel.anyLevel) === null || _currentLevel$anyLeve === void 0 ? void 0 : _currentLevel$anyLeve.length) || 0) + (((_currentLevel$thisLev = currentLevel.thisLevel) === null || _currentLevel$thisLev === void 0 ? void 0 : _currentLevel$thisLev.length) || 0); 43777 17765 var added = false;43778 -1 for (var _i8 = 0; _i8 < combined.length; _i8++) {43779 -1 var exp = combined[_i8];-1 17766 for (var _i8 = 0; _i8 < combinedLength; _i8++) { -1 17767 var _currentLevel$anyLeve2, _currentLevel$anyLeve3, _currentLevel$anyLeve4; -1 17768 var exp = _i8 < (((_currentLevel$anyLeve2 = currentLevel.anyLevel) === null || _currentLevel$anyLeve2 === void 0 ? void 0 : _currentLevel$anyLeve2.length) || 0) ? currentLevel.anyLevel[_i8] : currentLevel.thisLevel[_i8 - (((_currentLevel$anyLeve3 = currentLevel.anyLevel) === null || _currentLevel$anyLeve3 === void 0 ? void 0 : _currentLevel$anyLeve3.length) || 0)]; 43780 17769 if ((!exp[0].id || vNode.shadowId === currentLevel.parentShadowId) && _matchesExpression(vNode, exp[0])) { 43781 17770 if (exp.length === 1) { 43782 17771 if (!added && (!filter || filter(vNode))) { @@ -43789,21 +17778,22 @@ module.exports = { 43789 17778 throw new Error('axe.utils.querySelectorAll does not support the combinator: ' + exp[1].combinator); 43790 17779 } 43791 17780 if (rest[0].combinator === '>') {43792 -1 childOnly.push(rest);-1 17781 (childOnly = childOnly || []).push(rest); 43793 17782 } else {43794 -1 childAny.push(rest);-1 17783 (childAny = childAny || []).push(rest); 43795 17784 } 43796 17785 } 43797 17786 }43798 -1 if ((!exp[0].id || vNode.shadowId === currentLevel.parentShadowId) && currentLevel.anyLevel.includes(exp)) {43799 -1 childAny.push(exp);-1 17787 if ((!exp[0].id || vNode.shadowId === currentLevel.parentShadowId) && (_currentLevel$anyLeve4 = currentLevel.anyLevel) !== null && _currentLevel$anyLeve4 !== void 0 && _currentLevel$anyLeve4.includes(exp)) { -1 17788 (childAny = childAny || []).push(exp); 43800 17789 } 43801 17790 } 43802 17791 if (vNode.children && vNode.children.length) { 43803 17792 stack.push(currentLevel);43804 -1 currentLevel = createLocalVariables(vNode.children, childAny, childOnly, vNode.shadowId);-1 17793 currentLevel = createLocalVariables(vNode.children, childAny, childOnly, vNode.shadowId, recycledLocalVariables.pop()); 43805 17794 }43806 -1 while (!currentLevel.vNodes.length && stack.length) {-1 17795 while (currentLevel.vNodesIndex === currentLevel.vNodes.length && stack.length) { -1 17796 recycledLocalVariables.push(currentLevel); 43807 17797 currentLevel = stack.pop(); 43808 17798 } 43809 17799 } @@ -43815,8 +17805,8 @@ module.exports = { 43815 17805 return matchExpressions(domTree, expressions, filter); 43816 17806 } 43817 17807 var query_selector_all_filter_default = querySelectorAllFilter;43818 -1 function preloadCssom(_ref15) {43819 -1 var _ref15$treeRoot = _ref15.treeRoot, treeRoot = _ref15$treeRoot === void 0 ? axe._tree[0] : _ref15$treeRoot;-1 17808 function preloadCssom(_ref23) { -1 17809 var _ref23$treeRoot = _ref23.treeRoot, treeRoot = _ref23$treeRoot === void 0 ? axe._tree[0] : _ref23$treeRoot; 43820 17810 var rootNodes = getAllRootNodesInTree(treeRoot); 43821 17811 if (!rootNodes.length) { 43822 17812 return Promise.resolve(); @@ -43846,8 +17836,8 @@ module.exports = { 43846 17836 } 43847 17837 function getCssomForAllRootNodes(rootNodes, convertDataToStylesheet) { 43848 17838 var promises = [];43849 -1 rootNodes.forEach(function(_ref16, index) {43850 -1 var rootNode = _ref16.rootNode, shadowId = _ref16.shadowId;-1 17839 rootNodes.forEach(function(_ref24, index) { -1 17840 var rootNode = _ref24.rootNode, shadowId = _ref24.shadowId; 43851 17841 var sheets = getStylesheetsOfRootNode(rootNode, shadowId, convertDataToStylesheet); 43852 17842 if (!sheets) { 43853 17843 return Promise.all(promises); @@ -43928,10 +17918,10 @@ module.exports = { 43928 17918 return true; 43929 17919 }); 43930 17920 }43931 -1 function preloadMedia(_ref17) {43932 -1 var _ref17$treeRoot = _ref17.treeRoot, treeRoot = _ref17$treeRoot === void 0 ? axe._tree[0] : _ref17$treeRoot;43933 -1 var mediaVirtualNodes = query_selector_all_filter_default(treeRoot, 'video, audio', function(_ref18) {43934 -1 var actualNode = _ref18.actualNode;-1 17921 function preloadMedia(_ref25) { -1 17922 var _ref25$treeRoot = _ref25.treeRoot, treeRoot = _ref25$treeRoot === void 0 ? axe._tree[0] : _ref25$treeRoot; -1 17923 var mediaVirtualNodes = query_selector_all_filter_default(treeRoot, 'video, audio', function(_ref26) { -1 17924 var actualNode = _ref26.actualNode; 43935 17925 if (actualNode.hasAttribute('src')) { 43936 17926 return !!actualNode.getAttribute('src'); 43937 17927 } @@ -43943,8 +17933,8 @@ module.exports = { 43943 17933 } 43944 17934 return true; 43945 17935 });43946 -1 return Promise.all(mediaVirtualNodes.map(function(_ref19) {43947 -1 var actualNode = _ref19.actualNode;-1 17936 return Promise.all(mediaVirtualNodes.map(function(_ref27) { -1 17937 var actualNode = _ref27.actualNode; 43948 17938 return isMediaElementReady(actualNode); 43949 17939 })); 43950 17940 } @@ -44034,7 +18024,7 @@ module.exports = { 44034 18024 if (messages2.incomplete && messages2.incomplete['default']) { 44035 18025 return messages2.incomplete['default']; 44036 18026 } else {44037 -1 return incomplete_fallback_msg_default();-1 18027 return incompleteFallbackMessage(); 44038 18028 } 44039 18029 } 44040 18030 if (checkData && checkData.missingData) { @@ -44126,10 +18116,10 @@ module.exports = { 44126 18116 return false; 44127 18117 } 44128 18118 }44129 -1 function ruleShouldRun(rule3, context3, options) {-1 18119 function ruleShouldRun(rule3, context5, options) { 44130 18120 var runOnly = options.runOnly || {}; 44131 18121 var ruleOptions = (options.rules || {})[rule3.id];44132 -1 if (rule3.pageLevel && !context3.page) {-1 18122 if (rule3.pageLevel && !context5.page) { 44133 18123 return false; 44134 18124 } else if (runOnly.type === 'rule') { 44135 18125 return runOnly.values.indexOf(rule3.id) !== -1; @@ -44192,15 +18182,15 @@ module.exports = { 44192 18182 } 44193 18183 return result; 44194 18184 }44195 -1 function reduceIncludes(includes) {-1 18185 function getOuterIncludes(includes) { 44196 18186 return includes.reduce(function(res, el) {44197 -1 if (!res.length || !contains_default(res[res.length - 1], el)) {-1 18187 if (!res.length || !_contains(res[res.length - 1], el)) { 44198 18188 res.push(el); 44199 18189 } 44200 18190 return res; 44201 18191 }, []); 44202 18192 }44203 -1 function select(selector, context3) {-1 18193 function select(selector, context5) { 44204 18194 var result = []; 44205 18195 var candidate; 44206 18196 if (axe._selectCache) { @@ -44211,15 +18201,12 @@ module.exports = { 44211 18201 } 44212 18202 } 44213 18203 }44214 -1 var curried = function(context4) {44215 -1 return function(node) {44216 -1 return is_node_in_context_default(node, context4);44217 -1 };44218 -1 }(context3);44219 -1 var reducedIncludes = reduceIncludes(context3.include);44220 -1 for (var _i10 = 0; _i10 < reducedIncludes.length; _i10++) {44221 -1 candidate = reducedIncludes[_i10];44222 -1 result = pushNode(result, query_selector_all_filter_default(candidate, selector, curried));-1 18204 var outerIncludes = getOuterIncludes(context5.include); -1 18205 var isInContext = getContextFilter(context5); -1 18206 for (var _i10 = 0; _i10 < outerIncludes.length; _i10++) { -1 18207 candidate = outerIncludes[_i10]; -1 18208 var nodes = query_selector_all_filter_default(candidate, selector, isInContext); -1 18209 result = pushNode(result, nodes); 44223 18210 } 44224 18211 if (axe._selectCache) { 44225 18212 axe._selectCache.push({ @@ -44230,6 +18217,14 @@ module.exports = { 44230 18217 return result; 44231 18218 } 44232 18219 var select_default = select; -1 18220 function getContextFilter(context5) { -1 18221 if (!context5.exclude || context5.exclude.length === 0) { -1 18222 return null; -1 18223 } -1 18224 return function(node) { -1 18225 return is_node_in_context_default(node, context5); -1 18226 }; -1 18227 } 44233 18228 function setScroll(elm, top, left) { 44234 18229 if (elm === window) { 44235 18230 return elm.scroll(left, top); @@ -44239,12 +18234,27 @@ module.exports = { 44239 18234 } 44240 18235 } 44241 18236 function setScrollState(scrollState) {44242 -1 scrollState.forEach(function(_ref21) {44243 -1 var elm = _ref21.elm, top = _ref21.top, left = _ref21.left;-1 18237 scrollState.forEach(function(_ref29) { -1 18238 var elm = _ref29.elm, top = _ref29.top, left = _ref29.left; 44244 18239 return setScroll(elm, top, left); 44245 18240 }); 44246 18241 } 44247 18242 var set_scroll_state_default = setScrollState; -1 18243 function _shadowSelect(selectors) { -1 18244 var selectorArr = Array.isArray(selectors) ? _toConsumableArray(selectors) : [ selectors ]; -1 18245 return selectRecursive(selectorArr, document); -1 18246 } -1 18247 function selectRecursive(selectors, doc) { -1 18248 var selectorStr = selectors.shift(); -1 18249 var elm = selectorStr ? doc.querySelector(selectorStr) : null; -1 18250 if (selectors.length === 0) { -1 18251 return elm; -1 18252 } -1 18253 if (!(elm !== null && elm !== void 0 && elm.shadowRoot)) { -1 18254 return null; -1 18255 } -1 18256 return selectRecursive(selectors, elm.shadowRoot); -1 18257 } 44248 18258 function tokenList(str) { 44249 18259 return (str || '').trim().replace(/\s{2,}/g, ' ').split(' '); 44250 18260 } @@ -44292,12 +18302,12 @@ module.exports = { 44292 18302 _inherits(SerialVirtualNode, _abstract_virtual_nod2); 44293 18303 var _super2 = _createSuper(SerialVirtualNode); 44294 18304 function SerialVirtualNode(serialNode) {44295 -1 var _this2;-1 18305 var _this3; 44296 18306 _classCallCheck(this, SerialVirtualNode);44297 -1 _this2 = _super2.call(this);44298 -1 _this2._props = normaliseProps(serialNode);44299 -1 _this2._attrs = normaliseAttrs(serialNode);44300 -1 return _this2;-1 18307 _this3 = _super2.call(this); -1 18308 _this3._props = normaliseProps(serialNode); -1 18309 _this3._attrs = normaliseAttrs(serialNode); -1 18310 return _this3; 44301 18311 } 44302 18312 _createClass(SerialVirtualNode, [ { 44303 18313 key: 'props', @@ -44307,7 +18317,8 @@ module.exports = { 44307 18317 }, { 44308 18318 key: 'attr', 44309 18319 value: function attr(attrName) {44310 -1 return this._attrs[attrName] || null;-1 18320 var _this$_attrs$attrName; -1 18321 return (_this$_attrs$attrName = this._attrs[attrName]) !== null && _this$_attrs$attrName !== void 0 ? _this$_attrs$attrName : null; 44311 18322 } 44312 18323 }, { 44313 18324 key: 'hasAttr', @@ -44322,9 +18333,22 @@ module.exports = { 44322 18333 } ]); 44323 18334 return SerialVirtualNode; 44324 18335 }(abstract_virtual_node_default); -1 18336 var nodeNamesToTypes = { -1 18337 '#cdata-section': 2, -1 18338 '#text': 3, -1 18339 '#comment': 8, -1 18340 '#document': 9, -1 18341 '#document-fragment': 11 -1 18342 }; -1 18343 var nodeTypeToName = {}; -1 18344 var nodeNames = Object.keys(nodeNamesToTypes); -1 18345 nodeNames.forEach(function(nodeName2) { -1 18346 nodeTypeToName[nodeNamesToTypes[nodeName2]] = nodeName2; -1 18347 }); 44325 18348 function normaliseProps(serialNode) {44326 -1 var nodeName2 = serialNode.nodeName;44327 -1 var _serialNode$nodeType = serialNode.nodeType, nodeType = _serialNode$nodeType === void 0 ? 1 : _serialNode$nodeType;-1 18349 var _serialNode$nodeName, _ref30, _serialNode$nodeType; -1 18350 var nodeName2 = (_serialNode$nodeName = serialNode.nodeName) !== null && _serialNode$nodeName !== void 0 ? _serialNode$nodeName : nodeTypeToName[serialNode.nodeType]; -1 18351 var nodeType = (_ref30 = (_serialNode$nodeType = serialNode.nodeType) !== null && _serialNode$nodeType !== void 0 ? _serialNode$nodeType : nodeNamesToTypes[serialNode.nodeName]) !== null && _ref30 !== void 0 ? _ref30 : 1; 44328 18352 assert_default(typeof nodeType === 'number', 'nodeType has to be a number, got \''.concat(nodeType, '\'')); 44329 18353 assert_default(typeof nodeName2 === 'string', 'nodeName has to be a string, got \''.concat(nodeName2, '\'')); 44330 18354 nodeName2 = nodeName2.toLowerCase(); @@ -44345,8 +18369,8 @@ module.exports = { 44345 18369 delete props.attributes; 44346 18370 return Object.freeze(props); 44347 18371 }44348 -1 function normaliseAttrs(_ref22) {44349 -1 var _ref22$attributes = _ref22.attributes, attributes4 = _ref22$attributes === void 0 ? {} : _ref22$attributes;-1 18372 function normaliseAttrs(_ref31) { -1 18373 var _ref31$attributes = _ref31.attributes, attributes4 = _ref31$attributes === void 0 ? {} : _ref31$attributes; 44350 18374 var attrMap = { 44351 18375 htmlFor: 'for', 44352 18376 className: 'class' @@ -44488,7 +18512,7 @@ module.exports = { 44488 18512 } 44489 18513 var is_unsupported_role_default = isUnsupportedRole; 44490 18514 function isValidRole(role) {44491 -1 var _ref23 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, allowAbstract = _ref23.allowAbstract, _ref23$flagUnsupporte = _ref23.flagUnsupported, flagUnsupported = _ref23$flagUnsupporte === void 0 ? false : _ref23$flagUnsupporte;-1 18515 var _ref32 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, allowAbstract = _ref32.allowAbstract, _ref32$flagUnsupporte = _ref32.flagUnsupported, flagUnsupported = _ref32$flagUnsupporte === void 0 ? false : _ref32$flagUnsupporte; 44492 18516 var roleDefinition = standards_default.ariaRoles[role]; 44493 18517 var isRoleUnsupported = is_unsupported_role_default(role); 44494 18518 if (!roleDefinition || flagUnsupported && isRoleUnsupported) { @@ -44498,7 +18522,7 @@ module.exports = { 44498 18522 } 44499 18523 var is_valid_role_default = isValidRole; 44500 18524 function getExplicitRole(vNode) {44501 -1 var _ref24 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, fallback = _ref24.fallback, abstracts = _ref24.abstracts, dpub = _ref24.dpub;-1 18525 var _ref33 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, fallback = _ref33.fallback, abstracts = _ref33.abstracts, dpub = _ref33.dpub; 44502 18526 vNode = vNode instanceof abstract_virtual_node_default ? vNode : get_node_from_tree_default(vNode); 44503 18527 if (vNode.props.nodeType !== 1) { 44504 18528 return null; @@ -44769,6 +18793,10 @@ module.exports = { 44769 18793 return matcher === someString; 44770 18794 } 44771 18795 var from_primative_default = fromPrimative; -1 18796 function hasAccessibleName2(vNode, matcher) { -1 18797 return from_primative_default(!!accessible_text_virtual_default(vNode), matcher); -1 18798 } -1 18799 var has_accessible_name_default = hasAccessibleName2; 44772 18800 function fromFunction(getValue, matcher) { 44773 18801 var matcherType = _typeof(matcher); 44774 18802 if (matcherType !== 'object' || Array.isArray(matcher) || matcher instanceof RegExp) { @@ -44821,6 +18849,7 @@ module.exports = { 44821 18849 } 44822 18850 var semantic_role_default = semanticRole; 44823 18851 var matchers = { -1 18852 hasAccessibleName: has_accessible_name_default, 44824 18853 attributes: attributes_default, 44825 18854 condition: condition_default, 44826 18855 explicitRole: explicit_role_default, @@ -44855,6 +18884,7 @@ module.exports = { 44855 18884 return from_definition_default(vNode, definition); 44856 18885 } 44857 18886 var matches_default2 = matches5; -1 18887 matches_default2.hasAccessibleName = has_accessible_name_default; 44858 18888 matches_default2.attributes = attributes_default; 44859 18889 matches_default2.condition = condition_default; 44860 18890 matches_default2.explicitRole = explicit_role_default; @@ -44867,6 +18897,7 @@ module.exports = { 44867 18897 matches_default2.semanticRole = semantic_role_default; 44868 18898 var matches_default3 = matches_default2; 44869 18899 function getElementSpec(vNode) { -1 18900 var _ref34 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, _ref34$noMatchAccessi = _ref34.noMatchAccessibleName, noMatchAccessibleName = _ref34$noMatchAccessi === void 0 ? false : _ref34$noMatchAccessi; 44870 18901 var standard = standards_default.htmlElms[vNode.props.nodeName]; 44871 18902 if (!standard) { 44872 18903 return {}; @@ -44874,12 +18905,18 @@ module.exports = { 44874 18905 if (!standard.variant) { 44875 18906 return standard; 44876 18907 }44877 -1 var variant = standard.variant, spec = _objectWithoutProperties(standard, _excluded);-1 18908 var variant = standard.variant, spec = _objectWithoutProperties(standard, _excluded3); 44878 18909 for (var variantName in variant) { 44879 18910 if (!variant.hasOwnProperty(variantName) || variantName === 'default') { 44880 18911 continue; 44881 18912 }44882 -1 var _variant$variantName = variant[variantName], matches14 = _variant$variantName.matches, props = _objectWithoutProperties(_variant$variantName, _excluded2);-1 18913 var _variant$variantName = variant[variantName], matches14 = _variant$variantName.matches, props = _objectWithoutProperties(_variant$variantName, _excluded4); -1 18914 var matchProperties = Array.isArray(matches14) ? matches14 : [ matches14 ]; -1 18915 for (var _i12 = 0; _i12 < matchProperties.length && noMatchAccessibleName; _i12++) { -1 18916 if (matchProperties[_i12].hasOwnProperty('hasAccessibleName')) { -1 18917 return standard; -1 18918 } -1 18919 } 44883 18920 if (matches_default3(vNode, matches14)) { 44884 18921 for (var propName in props) { 44885 18922 if (props.hasOwnProperty(propName)) { @@ -44897,7 +18934,7 @@ module.exports = { 44897 18934 } 44898 18935 var get_element_spec_default = getElementSpec; 44899 18936 function implicitRole2(node) {44900 -1 var _ref25 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, chromium = _ref25.chromium;-1 18937 var _ref35 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, chromium = _ref35.chromium; 44901 18938 var vNode = node instanceof abstract_virtual_node_default ? node : get_node_from_tree_default(node); 44902 18939 node = vNode.actualNode; 44903 18940 if (!vNode) { @@ -44947,8 +18984,8 @@ module.exports = { 44947 18984 } 44948 18985 return getInheritedRole(vNode.parent, explicitRoleOptions); 44949 18986 }44950 -1 function resolveImplicitRole(vNode, _ref26) {44951 -1 var chromium = _ref26.chromium, explicitRoleOptions = _objectWithoutProperties(_ref26, _excluded3);-1 18987 function resolveImplicitRole(vNode, _ref36) { -1 18988 var chromium = _ref36.chromium, explicitRoleOptions = _objectWithoutProperties(_ref36, _excluded5); 44952 18989 var implicitRole3 = implicit_role_default(vNode, { 44953 18990 chromium: chromium 44954 18991 }); @@ -44968,8 +19005,8 @@ module.exports = { 44968 19005 return hasGlobalAria || is_focusable_default(vNode); 44969 19006 } 44970 19007 function resolveRole(node) {44971 -1 var _ref27 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};44972 -1 var noImplicit = _ref27.noImplicit, roleOptions = _objectWithoutProperties(_ref27, _excluded4);-1 19008 var _ref37 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; -1 19009 var noImplicit = _ref37.noImplicit, roleOptions = _objectWithoutProperties(_ref37, _excluded6); 44973 19010 var vNode = node instanceof abstract_virtual_node_default ? node : get_node_from_tree_default(node); 44974 19011 if (vNode.props.nodeType !== 1) { 44975 19012 return null; @@ -44987,8 +19024,8 @@ module.exports = { 44987 19024 return explicitRole2; 44988 19025 } 44989 19026 function getRole(node) {44990 -1 var _ref28 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};44991 -1 var noPresentational = _ref28.noPresentational, options = _objectWithoutProperties(_ref28, _excluded5);-1 19027 var _ref38 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; -1 19028 var noPresentational = _ref38.noPresentational, options = _objectWithoutProperties(_ref38, _excluded7); 44992 19029 var role = resolveRole(node, options); 44993 19030 if (noPresentational && [ 'presentation', 'none' ].includes(role)) { 44994 19031 return null; @@ -45009,7 +19046,7 @@ module.exports = { 45009 19046 } 45010 19047 var title_text_default = titleText; 45011 19048 function namedFromContents(vNode) {45012 -1 var _ref29 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, strict = _ref29.strict;-1 19049 var _ref39 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, strict = _ref39.strict; 45013 19050 vNode = vNode instanceof abstract_virtual_node_default ? vNode : get_node_from_tree_default(vNode); 45014 19051 if (vNode.props.nodeType !== 1) { 45015 19052 return false; @@ -45042,33 +19079,35 @@ module.exports = { 45042 19079 } 45043 19080 var get_owned_virtual_default = getOwnedVirtual; 45044 19081 function subtreeText(virtualNode) {45045 -1 var context3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};-1 19082 var context5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 45046 19083 var alreadyProcessed2 = accessible_text_virtual_default.alreadyProcessed;45047 -1 context3.startNode = context3.startNode || virtualNode;45048 -1 var _context = context3, strict = _context.strict, inControlContext = _context.inControlContext, inLabelledByContext = _context.inLabelledByContext;45049 -1 var _get_element_spec_def2 = get_element_spec_default(virtualNode), contentTypes = _get_element_spec_def2.contentTypes;45050 -1 if (alreadyProcessed2(virtualNode, context3) || virtualNode.props.nodeType !== 1 || contentTypes !== null && contentTypes !== void 0 && contentTypes.includes('embedded')) {-1 19084 context5.startNode = context5.startNode || virtualNode; -1 19085 var _context = context5, strict = _context.strict, inControlContext = _context.inControlContext, inLabelledByContext = _context.inLabelledByContext; -1 19086 var _get_element_spec_def2 = get_element_spec_default(virtualNode, { -1 19087 noMatchAccessibleName: true -1 19088 }), contentTypes = _get_element_spec_def2.contentTypes; -1 19089 if (alreadyProcessed2(virtualNode, context5) || virtualNode.props.nodeType !== 1 || contentTypes !== null && contentTypes !== void 0 && contentTypes.includes('embedded')) { 45051 19090 return ''; 45052 19091 } 45053 19092 if (!named_from_contents_default(virtualNode, { 45054 19093 strict: strict45055 -1 }) && !context3.subtreeDescendant) {-1 19094 }) && !context5.subtreeDescendant) { 45056 19095 return ''; 45057 19096 } 45058 19097 if (!strict) { 45059 19098 var subtreeDescendant = !inControlContext && !inLabelledByContext;45060 -1 context3 = _extends({-1 19099 context5 = _extends({ 45061 19100 subtreeDescendant: subtreeDescendant45062 -1 }, context3);-1 19101 }, context5); 45063 19102 } 45064 19103 return get_owned_virtual_default(virtualNode).reduce(function(contentText, child) {45065 -1 return appendAccessibleText(contentText, child, context3);-1 19104 return appendAccessibleText(contentText, child, context5); 45066 19105 }, ''); 45067 19106 } 45068 19107 var phrasingElements = get_elements_by_content_type_default('phrasing').concat([ '#text' ]);45069 -1 function appendAccessibleText(contentText, virtualNode, context3) {-1 19108 function appendAccessibleText(contentText, virtualNode, context5) { 45070 19109 var nodeName2 = virtualNode.props.nodeName;45071 -1 var contentTextAdd = accessible_text_virtual_default(virtualNode, context3);-1 19110 var contentTextAdd = accessible_text_virtual_default(virtualNode, context5); 45072 19111 if (!contentTextAdd) { 45073 19112 return contentText; 45074 19113 } @@ -45084,17 +19123,17 @@ module.exports = { 45084 19123 } 45085 19124 var subtree_text_default = subtreeText; 45086 19125 function labelText(virtualNode) {45087 -1 var context3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};-1 19126 var context5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 45088 19127 var alreadyProcessed2 = accessible_text_virtual_default.alreadyProcessed;45089 -1 if (context3.inControlContext || context3.inLabelledByContext || alreadyProcessed2(virtualNode, context3)) {-1 19128 if (context5.inControlContext || context5.inLabelledByContext || alreadyProcessed2(virtualNode, context5)) { 45090 19129 return ''; 45091 19130 }45092 -1 if (!context3.startNode) {45093 -1 context3.startNode = virtualNode;-1 19131 if (!context5.startNode) { -1 19132 context5.startNode = virtualNode; 45094 19133 } 45095 19134 var labelContext = _extends({ 45096 19135 inControlContext: true45097 -1 }, context3);-1 19136 }, context5); 45098 19137 var explicitLabels = getExplicitLabels(virtualNode); 45099 19138 var implicitLabel = closest_default(virtualNode, 'label'); 45100 19139 var labels; @@ -45132,12 +19171,12 @@ module.exports = { 45132 19171 button: '' 45133 19172 }; 45134 19173 var nativeTextMethods = {45135 -1 valueText: function valueText(_ref30) {45136 -1 var actualNode = _ref30.actualNode;-1 19174 valueText: function valueText(_ref40) { -1 19175 var actualNode = _ref40.actualNode; 45137 19176 return actualNode.value || ''; 45138 19177 },45139 -1 buttonDefaultText: function buttonDefaultText(_ref31) {45140 -1 var actualNode = _ref31.actualNode;-1 19178 buttonDefaultText: function buttonDefaultText(_ref41) { -1 19179 var actualNode = _ref41.actualNode; 45141 19180 return defaultButtonValues[actualNode.type] || ''; 45142 19181 }, 45143 19182 tableCaptionText: descendantText.bind(null, 'caption'), @@ -45157,34 +19196,36 @@ module.exports = { 45157 19196 function attrText(attr, vNode) { 45158 19197 return vNode.attr(attr) || ''; 45159 19198 }45160 -1 function descendantText(nodeName2, _ref32, context3) {45161 -1 var actualNode = _ref32.actualNode;-1 19199 function descendantText(nodeName2, _ref42, context5) { -1 19200 var actualNode = _ref42.actualNode; 45162 19201 nodeName2 = nodeName2.toLowerCase();45163 -1 var nodeNames = [ nodeName2, actualNode.nodeName.toLowerCase() ].join(',');45164 -1 var candidate = actualNode.querySelector(nodeNames);-1 19202 var nodeNames2 = [ nodeName2, actualNode.nodeName.toLowerCase() ].join(','); -1 19203 var candidate = actualNode.querySelector(nodeNames2); 45165 19204 if (!candidate || candidate.nodeName.toLowerCase() !== nodeName2) { 45166 19205 return ''; 45167 19206 }45168 -1 return accessible_text_default(candidate, context3);-1 19207 return accessible_text_default(candidate, context5); 45169 19208 } 45170 19209 var native_text_methods_default = nativeTextMethods; 45171 19210 function nativeTextAlternative(virtualNode) {45172 -1 var context3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};-1 19211 var context5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 45173 19212 var actualNode = virtualNode.actualNode; 45174 19213 if (virtualNode.props.nodeType !== 1 || [ 'presentation', 'none' ].includes(get_role_default(virtualNode))) { 45175 19214 return ''; 45176 19215 } 45177 19216 var textMethods = findTextMethods(virtualNode); 45178 19217 var accName = textMethods.reduce(function(accName2, step) {45179 -1 return accName2 || step(virtualNode, context3);-1 19218 return accName2 || step(virtualNode, context5); 45180 19219 }, '');45181 -1 if (context3.debug) {45182 -1 axe.log(accName || '{empty-value}', actualNode, context3);-1 19220 if (context5.debug) { -1 19221 axe.log(accName || '{empty-value}', actualNode, context5); 45183 19222 } 45184 19223 return accName; 45185 19224 } 45186 19225 function findTextMethods(virtualNode) {45187 -1 var elmSpec = get_element_spec_default(virtualNode);-1 19226 var elmSpec = get_element_spec_default(virtualNode, { -1 19227 noMatchAccessibleName: true -1 19228 }); 45188 19229 var methods = elmSpec.namingMethods || []; 45189 19230 return methods.map(function(methodName) { 45190 19231 return native_text_methods_default[methodName]; @@ -45239,21 +19280,21 @@ module.exports = { 45239 19280 ariaRangeValue: ariaRangeValue 45240 19281 }; 45241 19282 function formControlValue(virtualNode) {45242 -1 var context3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};-1 19283 var context5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 45243 19284 var actualNode = virtualNode.actualNode; 45244 19285 var unsupportedRoles = unsupported_default.accessibleNameFromFieldValue || []; 45245 19286 var role = get_role_default(virtualNode);45246 -1 if (context3.startNode === virtualNode || !controlValueRoles.includes(role) || unsupportedRoles.includes(role)) {-1 19287 if (context5.startNode === virtualNode || !controlValueRoles.includes(role) || unsupportedRoles.includes(role)) { 45247 19288 return ''; 45248 19289 } 45249 19290 var valueMethods = Object.keys(_formControlValueMethods).map(function(name) { 45250 19291 return _formControlValueMethods[name]; 45251 19292 }); 45252 19293 var valueString = valueMethods.reduce(function(accName, step) {45253 -1 return accName || step(virtualNode, context3);-1 19294 return accName || step(virtualNode, context5); 45254 19295 }, '');45255 -1 if (context3.debug) {45256 -1 log_default(valueString || '{empty-value}', actualNode, context3);-1 19296 if (context5.debug) { -1 19297 log_default(valueString || '{empty-value}', actualNode, context5); 45257 19298 } 45258 19299 return valueString; 45259 19300 } @@ -45271,7 +19312,7 @@ module.exports = { 45271 19312 } 45272 19313 var options = query_selector_all_default(vNode, 'option'); 45273 19314 var selectedOptions = options.filter(function(option) {45274 -1 return option.hasAttr('selected');-1 19315 return option.props.selected; 45275 19316 }); 45276 19317 if (!selectedOptions.length) { 45277 19318 selectedOptions.push(options[0]); @@ -45292,7 +19333,7 @@ module.exports = { 45292 19333 return actualNode.textContent; 45293 19334 } 45294 19335 }45295 -1 function ariaListboxValue(node, context3) {-1 19336 function ariaListboxValue(node, context5) { 45296 19337 var vNode = node instanceof abstract_virtual_node_default ? node : get_node_from_tree_default(node); 45297 19338 if (!is_aria_listbox_default(vNode)) { 45298 19339 return ''; @@ -45303,9 +19344,9 @@ module.exports = { 45303 19344 if (selected.length === 0) { 45304 19345 return ''; 45305 19346 }45306 -1 return accessible_text_virtual_default(selected[0], context3);-1 19347 return accessible_text_virtual_default(selected[0], context5); 45307 19348 }45308 -1 function ariaComboboxValue(node, context3) {-1 19349 function ariaComboboxValue(node, context5) { 45309 19350 var vNode = node instanceof abstract_virtual_node_default ? node : get_node_from_tree_default(node); 45310 19351 if (!is_aria_combobox_default(vNode)) { 45311 19352 return ''; @@ -45313,7 +19354,7 @@ module.exports = { 45313 19354 var listbox = get_owned_virtual_default(vNode).filter(function(elm) { 45314 19355 return get_role_default(elm) === 'listbox'; 45315 19356 })[0];45316 -1 return listbox ? ariaListboxValue(listbox, context3) : '';-1 19357 return listbox ? ariaListboxValue(listbox, context5) : ''; 45317 19358 } 45318 19359 function ariaRangeValue(node) { 45319 19360 var vNode = node instanceof abstract_virtual_node_default ? node : get_node_from_tree_default(node); @@ -45324,25 +19365,137 @@ module.exports = { 45324 19365 return !isNaN(valueNow) ? String(valueNow) : '0'; 45325 19366 } 45326 19367 var form_control_value_default = formControlValue; -1 19368 function getUnicodeNonBmpRegExp() { -1 19369 return /[\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u20A0-\u20CF\u20D0-\u20FF\u2100-\u214F\u2150-\u218F\u2190-\u21FF\u2200-\u22FF\u2300-\u23FF\u2400-\u243F\u2440-\u245F\u2460-\u24FF\u2500-\u257F\u2580-\u259F\u25A0-\u25FF\u2600-\u26FF\u2700-\u27BF\uE000-\uF8FF]/g; -1 19370 } -1 19371 function getPunctuationRegExp() { -1 19372 return /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&\xa3\xa2\xa5\xa7\u20ac()*+,\-.\/:;<=>?@\[\]^_`{|}~\xb1]/g; -1 19373 } -1 19374 function getSupplementaryPrivateUseRegExp() { -1 19375 return /[\uDB80-\uDBBF][\uDC00-\uDFFF]/g; -1 19376 } -1 19377 var emoji_regex = __toModule(require_emoji_regex()); -1 19378 function hasUnicode(str, options) { -1 19379 var emoji = options.emoji, nonBmp = options.nonBmp, punctuations = options.punctuations; -1 19380 if (emoji) { -1 19381 return emoji_regex['default']().test(str); -1 19382 } -1 19383 if (nonBmp) { -1 19384 return getUnicodeNonBmpRegExp().test(str) || getSupplementaryPrivateUseRegExp().test(str); -1 19385 } -1 19386 if (punctuations) { -1 19387 return getPunctuationRegExp().test(str); -1 19388 } -1 19389 return false; -1 19390 } -1 19391 var has_unicode_default = hasUnicode; -1 19392 function isIconLigature(textVNode) { -1 19393 var differenceThreshold = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : .15; -1 19394 var occuranceThreshold = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3; -1 19395 var nodeValue = textVNode.actualNode.nodeValue.trim(); -1 19396 if (!sanitize_default(nodeValue) || has_unicode_default(nodeValue, { -1 19397 emoji: true, -1 19398 nonBmp: true -1 19399 })) { -1 19400 return false; -1 19401 } -1 19402 if (!cache_default.get('canvasContext')) { -1 19403 cache_default.set('canvasContext', document.createElement('canvas').getContext('2d')); -1 19404 } -1 19405 var canvasContext = cache_default.get('canvasContext'); -1 19406 var canvas = canvasContext.canvas; -1 19407 if (!cache_default.get('fonts')) { -1 19408 cache_default.set('fonts', {}); -1 19409 } -1 19410 var fonts = cache_default.get('fonts'); -1 19411 var style = window.getComputedStyle(textVNode.parent.actualNode); -1 19412 var fontFamily = style.getPropertyValue('font-family'); -1 19413 if (!fonts[fontFamily]) { -1 19414 fonts[fontFamily] = { -1 19415 occurances: 0, -1 19416 numLigatures: 0 -1 19417 }; -1 19418 } -1 19419 var font = fonts[fontFamily]; -1 19420 if (font.occurances >= occuranceThreshold) { -1 19421 if (font.numLigatures / font.occurances === 1) { -1 19422 return true; -1 19423 } else if (font.numLigatures === 0) { -1 19424 return false; -1 19425 } -1 19426 } -1 19427 font.occurances++; -1 19428 var fontSize = 30; -1 19429 var fontStyle = ''.concat(fontSize, 'px ').concat(fontFamily); -1 19430 canvasContext.font = fontStyle; -1 19431 var firstChar = nodeValue.charAt(0); -1 19432 var width = canvasContext.measureText(firstChar).width; -1 19433 if (width < 30) { -1 19434 var diff = 30 / width; -1 19435 width *= diff; -1 19436 fontSize *= diff; -1 19437 fontStyle = ''.concat(fontSize, 'px ').concat(fontFamily); -1 19438 } -1 19439 canvas.width = width; -1 19440 canvas.height = fontSize; -1 19441 canvasContext.font = fontStyle; -1 19442 canvasContext.textAlign = 'left'; -1 19443 canvasContext.textBaseline = 'top'; -1 19444 canvasContext.fillText(firstChar, 0, 0); -1 19445 var compareData = new Uint32Array(canvasContext.getImageData(0, 0, width, fontSize).data.buffer); -1 19446 if (!compareData.some(function(pixel) { -1 19447 return pixel; -1 19448 })) { -1 19449 font.numLigatures++; -1 19450 return true; -1 19451 } -1 19452 canvasContext.clearRect(0, 0, width, fontSize); -1 19453 canvasContext.fillText(nodeValue, 0, 0); -1 19454 var compareWith = new Uint32Array(canvasContext.getImageData(0, 0, width, fontSize).data.buffer); -1 19455 var differences = compareData.reduce(function(diff, pixel, i) { -1 19456 if (pixel === 0 && compareWith[i] === 0) { -1 19457 return diff; -1 19458 } -1 19459 if (pixel !== 0 && compareWith[i] !== 0) { -1 19460 return diff; -1 19461 } -1 19462 return ++diff; -1 19463 }, 0); -1 19464 var expectedWidth = nodeValue.split('').reduce(function(width2, _char3) { -1 19465 return width2 + canvasContext.measureText(_char3).width; -1 19466 }, 0); -1 19467 var actualWidth = canvasContext.measureText(nodeValue).width; -1 19468 var pixelDifference = differences / compareData.length; -1 19469 var sizeDifference = 1 - actualWidth / expectedWidth; -1 19470 if (pixelDifference >= differenceThreshold && sizeDifference >= differenceThreshold) { -1 19471 font.numLigatures++; -1 19472 return true; -1 19473 } -1 19474 return false; -1 19475 } -1 19476 var is_icon_ligature_default = isIconLigature; 45327 19477 function accessibleTextVirtual(virtualNode) {45328 -1 var context3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};-1 19478 var context5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 45329 19479 var actualNode = virtualNode.actualNode;45330 -1 context3 = prepareContext(virtualNode, context3);45331 -1 if (shouldIgnoreHidden(virtualNode, context3)) {-1 19480 context5 = prepareContext(virtualNode, context5); -1 19481 if (shouldIgnoreHidden(virtualNode, context5)) { -1 19482 return ''; -1 19483 } -1 19484 if (shouldIgnoreIconLigature(virtualNode, context5)) { 45332 19485 return ''; 45333 19486 } 45334 19487 var computationSteps = [ arialabelledby_text_default, arialabel_text_default, native_text_alternative_default, form_control_value_default, subtree_text_default, textNodeValue, title_text_default ]; 45335 19488 var accName = computationSteps.reduce(function(accName2, step) {45336 -1 if (context3.startNode === virtualNode) {-1 19489 if (context5.startNode === virtualNode) { 45337 19490 accName2 = sanitize_default(accName2); 45338 19491 } 45339 19492 if (accName2 !== '') { 45340 19493 return accName2; 45341 19494 }45342 -1 return step(virtualNode, context3);-1 19495 return step(virtualNode, context5); 45343 19496 }, '');45344 -1 if (context3.debug) {45345 -1 axe.log(accName || '{empty-value}', actualNode, context3);-1 19497 if (context5.debug) { -1 19498 axe.log(accName || '{empty-value}', actualNode, context5); 45346 19499 } 45347 19500 return accName; 45348 19501 } @@ -45352,56 +19505,63 @@ module.exports = { 45352 19505 } 45353 19506 return virtualNode.props.nodeValue; 45354 19507 }45355 -1 function shouldIgnoreHidden(_ref33, context3) {45356 -1 var actualNode = _ref33.actualNode;-1 19508 function shouldIgnoreHidden(_ref43, context5) { -1 19509 var actualNode = _ref43.actualNode; 45357 19510 if (!actualNode) { 45358 19511 return false; 45359 19512 }45360 -1 if (actualNode.nodeType !== 1 || context3.includeHidden) {-1 19513 if (actualNode.nodeType !== 1 || context5.includeHidden) { 45361 19514 return false; 45362 19515 } 45363 19516 return !is_visible_default(actualNode, true); 45364 19517 }45365 -1 function prepareContext(virtualNode, context3) {-1 19518 function shouldIgnoreIconLigature(virtualNode, context5) { -1 19519 var ignoreIconLigature = context5.ignoreIconLigature, pixelThreshold = context5.pixelThreshold, occuranceThreshold = context5.occuranceThreshold; -1 19520 if (virtualNode.props.nodeType !== 3 || !ignoreIconLigature) { -1 19521 return false; -1 19522 } -1 19523 return is_icon_ligature_default(virtualNode, pixelThreshold, occuranceThreshold); -1 19524 } -1 19525 function prepareContext(virtualNode, context5) { 45366 19526 var actualNode = virtualNode.actualNode;45367 -1 if (!context3.startNode) {45368 -1 context3 = _extends({-1 19527 if (!context5.startNode) { -1 19528 context5 = _extends({ 45369 19529 startNode: virtualNode45370 -1 }, context3);-1 19530 }, context5); 45371 19531 } 45372 19532 if (!actualNode) {45373 -1 return context3;-1 19533 return context5; 45374 19534 }45375 -1 if (actualNode.nodeType === 1 && context3.inLabelledByContext && context3.includeHidden === void 0) {45376 -1 context3 = _extends({-1 19535 if (actualNode.nodeType === 1 && context5.inLabelledByContext && context5.includeHidden === void 0) { -1 19536 context5 = _extends({ 45377 19537 includeHidden: !is_visible_default(actualNode, true)45378 -1 }, context3);-1 19538 }, context5); 45379 19539 }45380 -1 return context3;-1 19540 return context5; 45381 19541 }45382 -1 accessibleTextVirtual.alreadyProcessed = function alreadyProcessed(virtualnode, context3) {45383 -1 context3.processed = context3.processed || [];45384 -1 if (context3.processed.includes(virtualnode)) {-1 19542 accessibleTextVirtual.alreadyProcessed = function alreadyProcessed(virtualnode, context5) { -1 19543 context5.processed = context5.processed || []; -1 19544 if (context5.processed.includes(virtualnode)) { 45385 19545 return true; 45386 19546 }45387 -1 context3.processed.push(virtualnode);-1 19547 context5.processed.push(virtualnode); 45388 19548 return false; 45389 19549 }; 45390 19550 var accessible_text_virtual_default = accessibleTextVirtual;45391 -1 function accessibleText(element, context3) {-1 19551 function accessibleText(element, context5) { 45392 19552 var virtualNode = get_node_from_tree_default(element);45393 -1 return accessible_text_virtual_default(virtualNode, context3);-1 19553 return accessible_text_virtual_default(virtualNode, context5); 45394 19554 } 45395 19555 var accessible_text_default = accessibleText; 45396 19556 function arialabelledbyText(vNode) {45397 -1 var context3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};-1 19557 var context5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 45398 19558 if (!(vNode instanceof abstract_virtual_node_default)) { 45399 19559 if (vNode.nodeType !== 1) { 45400 19560 return ''; 45401 19561 } 45402 19562 vNode = get_node_from_tree_default(vNode); 45403 19563 }45404 -1 if (vNode.props.nodeType !== 1 || context3.inLabelledByContext || context3.inControlContext || !vNode.attr('aria-labelledby')) {-1 19564 if (vNode.props.nodeType !== 1 || context5.inLabelledByContext || context5.inControlContext || !vNode.attr('aria-labelledby')) { 45405 19565 return ''; 45406 19566 } 45407 19567 var refs = idrefs_default(vNode, 'aria-labelledby').filter(function(elm) { @@ -45410,8 +19570,8 @@ module.exports = { 45410 19570 return refs.reduce(function(accessibleName, elm) { 45411 19571 var accessibleNameAdd = accessible_text_default(elm, _extends({ 45412 19572 inLabelledByContext: true,45413 -1 startNode: context3.startNode || vNode45414 -1 }, context3));-1 19573 startNode: context5.startNode || vNode -1 19574 }, context5)); 45415 19575 if (!accessibleName) { 45416 19576 return accessibleNameAdd; 45417 19577 } else { @@ -45492,30 +19652,6 @@ module.exports = { 45492 19652 return visible_virtual_default; 45493 19653 } 45494 19654 });45495 -1 function getUnicodeNonBmpRegExp() {45496 -1 return /[\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u20A0-\u20CF\u20D0-\u20FF\u2100-\u214F\u2150-\u218F\u2190-\u21FF\u2200-\u22FF\u2300-\u23FF\u2400-\u243F\u2440-\u245F\u2460-\u24FF\u2500-\u257F\u2580-\u259F\u25A0-\u25FF\u2600-\u26FF\u2700-\u27BF\uE000-\uF8FF]/g;45497 -1 }45498 -1 function getPunctuationRegExp() {45499 -1 return /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&\xa3\xa2\xa5\xa7\u20ac()*+,\-.\/:;<=>?@\[\]^_`{|}~\xb1]/g;45500 -1 }45501 -1 function getSupplementaryPrivateUseRegExp() {45502 -1 return /[\uDB80-\uDBBF][\uDC00-\uDFFF]/g;45503 -1 }45504 -1 var emoji_regex = __toModule(require_emoji_regex());45505 -1 function hasUnicode(str, options) {45506 -1 var emoji = options.emoji, nonBmp = options.nonBmp, punctuations = options.punctuations;45507 -1 if (emoji) {45508 -1 return emoji_regex['default']().test(str);45509 -1 }45510 -1 if (nonBmp) {45511 -1 return getUnicodeNonBmpRegExp().test(str) || getSupplementaryPrivateUseRegExp().test(str);45512 -1 }45513 -1 if (punctuations) {45514 -1 return getPunctuationRegExp().test(str);45515 -1 }45516 -1 return false;45517 -1 }45518 -1 var has_unicode_default = hasUnicode;45519 19655 var emoji_regex2 = __toModule(require_emoji_regex()); 45520 19656 function removeUnicode(str, options) { 45521 19657 var emoji = options.emoji, nonBmp = options.nonBmp, punctuations = options.punctuations; @@ -45551,91 +19687,6 @@ module.exports = { 45551 19687 return 1; 45552 19688 } 45553 19689 var is_human_interpretable_default = isHumanInterpretable;45554 -1 function isIconLigature(textVNode) {45555 -1 var differenceThreshold = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : .15;45556 -1 var occuranceThreshold = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;45557 -1 var nodeValue = textVNode.actualNode.nodeValue.trim();45558 -1 if (!sanitize_default(nodeValue) || has_unicode_default(nodeValue, {45559 -1 emoji: true,45560 -1 nonBmp: true45561 -1 })) {45562 -1 return false;45563 -1 }45564 -1 if (!cache_default.get('canvasContext')) {45565 -1 cache_default.set('canvasContext', document.createElement('canvas').getContext('2d'));45566 -1 }45567 -1 var canvasContext = cache_default.get('canvasContext');45568 -1 var canvas = canvasContext.canvas;45569 -1 if (!cache_default.get('fonts')) {45570 -1 cache_default.set('fonts', {});45571 -1 }45572 -1 var fonts = cache_default.get('fonts');45573 -1 var style = window.getComputedStyle(textVNode.parent.actualNode);45574 -1 var fontFamily = style.getPropertyValue('font-family');45575 -1 if (!fonts[fontFamily]) {45576 -1 fonts[fontFamily] = {45577 -1 occurances: 0,45578 -1 numLigatures: 045579 -1 };45580 -1 }45581 -1 var font = fonts[fontFamily];45582 -1 if (font.occurances >= occuranceThreshold) {45583 -1 if (font.numLigatures / font.occurances === 1) {45584 -1 return true;45585 -1 } else if (font.numLigatures === 0) {45586 -1 return false;45587 -1 }45588 -1 }45589 -1 font.occurances++;45590 -1 var fontSize = 30;45591 -1 var fontStyle = ''.concat(fontSize, 'px ').concat(fontFamily);45592 -1 canvasContext.font = fontStyle;45593 -1 var firstChar = nodeValue.charAt(0);45594 -1 var width = canvasContext.measureText(firstChar).width;45595 -1 if (width < 30) {45596 -1 var diff = 30 / width;45597 -1 width *= diff;45598 -1 fontSize *= diff;45599 -1 fontStyle = ''.concat(fontSize, 'px ').concat(fontFamily);45600 -1 }45601 -1 canvas.width = width;45602 -1 canvas.height = fontSize;45603 -1 canvasContext.font = fontStyle;45604 -1 canvasContext.textAlign = 'left';45605 -1 canvasContext.textBaseline = 'top';45606 -1 canvasContext.fillText(firstChar, 0, 0);45607 -1 var compareData = new Uint32Array(canvasContext.getImageData(0, 0, width, fontSize).data.buffer);45608 -1 if (!compareData.some(function(pixel) {45609 -1 return pixel;45610 -1 })) {45611 -1 font.numLigatures++;45612 -1 return true;45613 -1 }45614 -1 canvasContext.clearRect(0, 0, width, fontSize);45615 -1 canvasContext.fillText(nodeValue, 0, 0);45616 -1 var compareWith = new Uint32Array(canvasContext.getImageData(0, 0, width, fontSize).data.buffer);45617 -1 var differences = compareData.reduce(function(diff, pixel, i) {45618 -1 if (pixel === 0 && compareWith[i] === 0) {45619 -1 return diff;45620 -1 }45621 -1 if (pixel !== 0 && compareWith[i] !== 0) {45622 -1 return diff;45623 -1 }45624 -1 return ++diff;45625 -1 }, 0);45626 -1 var expectedWidth = nodeValue.split('').reduce(function(width2, _char3) {45627 -1 return width2 + canvasContext.measureText(_char3).width;45628 -1 }, 0);45629 -1 var actualWidth = canvasContext.measureText(nodeValue).width;45630 -1 var pixelDifference = differences / compareData.length;45631 -1 var sizeDifference = 1 - actualWidth / expectedWidth;45632 -1 if (pixelDifference >= differenceThreshold && sizeDifference >= differenceThreshold) {45633 -1 font.numLigatures++;45634 -1 return true;45635 -1 }45636 -1 return false;45637 -1 }45638 -1 var is_icon_ligature_default = isIconLigature;45639 19690 var _autocomplete = { 45640 19691 stateTerms: [ 'on', 'off' ], 45641 19692 standaloneTerms: [ 'name', 'honorific-prefix', 'given-name', 'additional-name', 'family-name', 'honorific-suffix', 'nickname', 'username', 'new-password', 'current-password', 'organization-title', 'organization', 'street-address', 'address-line1', 'address-line2', 'address-line3', 'address-level4', 'address-level3', 'address-level2', 'address-level1', 'country', 'country-name', 'postal-code', 'cc-name', 'cc-given-name', 'cc-additional-name', 'cc-family-name', 'cc-number', 'cc-exp', 'cc-exp-month', 'cc-exp-year', 'cc-csc', 'cc-type', 'transaction-currency', 'transaction-amount', 'language', 'bday', 'bday-day', 'bday-month', 'bday-year', 'sex', 'url', 'photo', 'one-time-code' ], @@ -45644,7 +19695,7 @@ module.exports = { 45644 19695 locations: [ 'billing', 'shipping' ] 45645 19696 }; 45646 19697 function isValidAutocomplete(autocompleteValue) {45647 -1 var _ref34 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, _ref34$looseTyped = _ref34.looseTyped, looseTyped = _ref34$looseTyped === void 0 ? false : _ref34$looseTyped, _ref34$stateTerms = _ref34.stateTerms, stateTerms = _ref34$stateTerms === void 0 ? [] : _ref34$stateTerms, _ref34$locations = _ref34.locations, locations = _ref34$locations === void 0 ? [] : _ref34$locations, _ref34$qualifiers = _ref34.qualifiers, qualifiers = _ref34$qualifiers === void 0 ? [] : _ref34$qualifiers, _ref34$standaloneTerm = _ref34.standaloneTerms, standaloneTerms = _ref34$standaloneTerm === void 0 ? [] : _ref34$standaloneTerm, _ref34$qualifiedTerms = _ref34.qualifiedTerms, qualifiedTerms = _ref34$qualifiedTerms === void 0 ? [] : _ref34$qualifiedTerms;-1 19698 var _ref44 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, _ref44$looseTyped = _ref44.looseTyped, looseTyped = _ref44$looseTyped === void 0 ? false : _ref44$looseTyped, _ref44$stateTerms = _ref44.stateTerms, stateTerms = _ref44$stateTerms === void 0 ? [] : _ref44$stateTerms, _ref44$locations = _ref44.locations, locations = _ref44$locations === void 0 ? [] : _ref44$locations, _ref44$qualifiers = _ref44.qualifiers, qualifiers = _ref44$qualifiers === void 0 ? [] : _ref44$qualifiers, _ref44$standaloneTerm = _ref44.standaloneTerms, standaloneTerms = _ref44$standaloneTerm === void 0 ? [] : _ref44$standaloneTerm, _ref44$qualifiedTerms = _ref44.qualifiedTerms, qualifiedTerms = _ref44$qualifiedTerms === void 0 ? [] : _ref44$qualifiedTerms; 45648 19699 autocompleteValue = autocompleteValue.toLowerCase().trim(); 45649 19700 stateTerms = stateTerms.concat(_autocomplete.stateTerms); 45650 19701 if (stateTerms.includes(autocompleteValue) || autocompleteValue === '') { @@ -45795,8 +19846,8 @@ module.exports = { 45795 19846 idRefs[id] = idRefs[id] || []; 45796 19847 idRefs[id].push(node); 45797 19848 }45798 -1 for (var _i12 = 0; _i12 < refAttrs.length; ++_i12) {45799 -1 var attr = refAttrs[_i12];-1 19849 for (var _i13 = 0; _i13 < refAttrs.length; ++_i13) { -1 19850 var attr = refAttrs[_i13]; 45800 19851 var attrValue = sanitize_default(node.getAttribute(attr) || ''); 45801 19852 if (!attrValue) { 45802 19853 continue; @@ -45808,8 +19859,10 @@ module.exports = { 45808 19859 } 45809 19860 } 45810 19861 }45811 -1 for (var _i13 = 0; _i13 < node.children.length; _i13++) {45812 -1 cacheIdRefs(node.children[_i13], idRefs, refAttrs);-1 19862 for (var _i14 = 0; _i14 < node.childNodes.length; _i14++) { -1 19863 if (node.childNodes[_i14].nodeType === 1) { -1 19864 cacheIdRefs(node.childNodes[_i14], idRefs, refAttrs); -1 19865 } 45813 19866 } 45814 19867 } 45815 19868 function getAccessibleRefs(node) { @@ -45845,61 +19898,55 @@ module.exports = { 45845 19898 function isAriaRoleAllowedOnElement(node, role) { 45846 19899 var vNode = node instanceof abstract_virtual_node_default ? node : get_node_from_tree_default(node); 45847 19900 var implicitRole3 = implicit_role_default(vNode);45848 -1 if (role === implicitRole3) {45849 -1 return true;45850 -1 }45851 19901 var spec = get_element_spec_default(vNode); 45852 19902 if (Array.isArray(spec.allowedRoles)) { 45853 19903 return spec.allowedRoles.includes(role); 45854 19904 } -1 19905 if (role === implicitRole3) { -1 19906 return false; -1 19907 } 45855 19908 return !!spec.allowedRoles; 45856 19909 } 45857 19910 var is_aria_role_allowed_on_element_default = isAriaRoleAllowedOnElement; 45858 19911 var dpubRoles2 = [ 'doc-backlink', 'doc-biblioentry', 'doc-biblioref', 'doc-cover', 'doc-endnote', 'doc-glossref', 'doc-noteref' ];45859 -1 function getRoleSegments(node) {-1 19912 var landmarkRoles = { -1 19913 header: 'banner', -1 19914 footer: 'contentinfo' -1 19915 }; -1 19916 function getRoleSegments(vNode) { 45860 19917 var roles = [];45861 -1 if (!node) {-1 19918 if (!vNode) { 45862 19919 return roles; 45863 19920 }45864 -1 if (node.hasAttribute('role')) {45865 -1 var nodeRoles = token_list_default(node.getAttribute('role').toLowerCase());-1 19921 if (vNode.hasAttr('role')) { -1 19922 var nodeRoles = token_list_default(vNode.attr('role').toLowerCase()); 45866 19923 roles = roles.concat(nodeRoles); 45867 19924 }45868 -1 if (node.hasAttributeNS('http://www.idpf.org/2007/ops', 'type')) {45869 -1 var epubRoles = token_list_default(node.getAttributeNS('http://www.idpf.org/2007/ops', 'type').toLowerCase()).map(function(role) {45870 -1 return 'doc-'.concat(role);45871 -1 });45872 -1 roles = roles.concat(epubRoles);45873 -1 }45874 -1 roles = roles.filter(function(role) {-1 19925 return roles.filter(function(role) { 45875 19926 return is_valid_role_default(role); 45876 19927 });45877 -1 return roles;45878 19928 } 45879 19929 function getElementUnallowedRoles(node) { 45880 19930 var allowImplicit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;45881 -1 var tagName = node.nodeName.toUpperCase();45882 -1 if (!is_html_element_default(node)) {-1 19931 var vNode = node instanceof abstract_virtual_node_default ? node : get_node_from_tree_default(node); -1 19932 if (!is_html_element_default(vNode)) { 45883 19933 return []; 45884 19934 }45885 -1 var roleSegments = getRoleSegments(node);45886 -1 var implicitRole3 = implicit_role_default(node);45887 -1 var unallowedRoles = roleSegments.filter(function(role) {45888 -1 if (allowImplicit && role === implicitRole3) {45889 -1 return false;45890 -1 }45891 -1 if (allowImplicit && dpubRoles2.includes(role)) {45892 -1 var roleType = get_role_type_default(role);45893 -1 if (implicitRole3 !== roleType) {45894 -1 return true;45895 -1 }45896 -1 }45897 -1 if (!allowImplicit && !(role === 'row' && tagName === 'TR' && element_matches_default(node, 'table[role="grid"] > tr'))) {45898 -1 return true;45899 -1 }45900 -1 return !is_aria_role_allowed_on_element_default(node, role);-1 19935 var nodeName2 = vNode.props.nodeName; -1 19936 var implicitRole3 = implicit_role_default(vNode) || landmarkRoles[nodeName2]; -1 19937 var roleSegments = getRoleSegments(vNode); -1 19938 return roleSegments.filter(function(role) { -1 19939 return !roleIsAllowed(role, vNode, allowImplicit, implicitRole3); 45901 19940 });45902 -1 return unallowedRoles;-1 19941 } -1 19942 function roleIsAllowed(role, vNode, allowImplicit, implicitRole3) { -1 19943 if (allowImplicit && role === implicitRole3) { -1 19944 return true; -1 19945 } -1 19946 if (dpubRoles2.includes(role) && get_role_type_default(role) !== implicitRole3) { -1 19947 return false; -1 19948 } -1 19949 return is_aria_role_allowed_on_element_default(vNode, role); 45903 19950 } 45904 19951 var get_element_unallowed_roles_default = getElementUnallowedRoles; 45905 19952 function getAriaRolesByType(type) { @@ -47309,2213 +21356,2934 @@ module.exports = { 47309 21356 rowheader: { 47310 21357 type: 'structure', 47311 21358 attributes: {47312 -1 allowed: [ 'aria-colindex', 'aria-colspan', 'aria-expanded', 'aria-rowindex', 'aria-rowspan', 'aria-required', 'aria-readonly', 'aria-selected', 'aria-sort', 'aria-errormessage' ]-1 21359 allowed: [ 'aria-colindex', 'aria-colspan', 'aria-expanded', 'aria-rowindex', 'aria-rowspan', 'aria-required', 'aria-readonly', 'aria-selected', 'aria-sort', 'aria-errormessage' ] -1 21360 }, -1 21361 owned: null, -1 21362 nameFrom: [ 'author', 'contents' ], -1 21363 context: [ 'row' ], -1 21364 implicit: [ 'th' ], -1 21365 unsupported: false -1 21366 }, -1 21367 scrollbar: { -1 21368 type: 'widget', -1 21369 attributes: { -1 21370 required: [ 'aria-controls', 'aria-valuenow' ], -1 21371 allowed: [ 'aria-valuetext', 'aria-orientation', 'aria-errormessage', 'aria-valuemax', 'aria-valuemin' ] -1 21372 }, -1 21373 owned: null, -1 21374 nameFrom: [ 'author' ], -1 21375 context: null, -1 21376 unsupported: false -1 21377 }, -1 21378 search: { -1 21379 type: 'landmark', -1 21380 attributes: { -1 21381 allowed: [ 'aria-expanded', 'aria-errormessage' ] -1 21382 }, -1 21383 owned: null, -1 21384 nameFrom: [ 'author' ], -1 21385 context: null, -1 21386 unsupported: false, -1 21387 allowedElements: { -1 21388 nodeName: [ 'aside', 'form', 'section' ] -1 21389 } -1 21390 }, -1 21391 searchbox: { -1 21392 type: 'widget', -1 21393 attributes: { -1 21394 allowed: [ 'aria-activedescendant', 'aria-autocomplete', 'aria-multiline', 'aria-readonly', 'aria-required', 'aria-placeholder', 'aria-errormessage' ] -1 21395 }, -1 21396 owned: null, -1 21397 nameFrom: [ 'author' ], -1 21398 context: null, -1 21399 implicit: [ 'input[type="search"]' ], -1 21400 unsupported: false, -1 21401 allowedElements: { -1 21402 nodeName: 'input', -1 21403 properties: { -1 21404 type: 'text' -1 21405 } -1 21406 } -1 21407 }, -1 21408 section: { -1 21409 nameFrom: [ 'author', 'contents' ], -1 21410 type: 'abstract', -1 21411 unsupported: false -1 21412 }, -1 21413 sectionhead: { -1 21414 nameFrom: [ 'author', 'contents' ], -1 21415 type: 'abstract', -1 21416 unsupported: false -1 21417 }, -1 21418 select: { -1 21419 nameFrom: [ 'author' ], -1 21420 type: 'abstract', -1 21421 unsupported: false -1 21422 }, -1 21423 separator: { -1 21424 type: 'structure', -1 21425 attributes: { -1 21426 allowed: [ 'aria-expanded', 'aria-orientation', 'aria-valuenow', 'aria-valuemax', 'aria-valuemin', 'aria-valuetext', 'aria-errormessage' ] -1 21427 }, -1 21428 owned: null, -1 21429 nameFrom: [ 'author' ], -1 21430 context: null, -1 21431 implicit: [ 'hr' ], -1 21432 unsupported: false, -1 21433 allowedElements: [ 'li' ] -1 21434 }, -1 21435 slider: { -1 21436 type: 'widget', -1 21437 attributes: { -1 21438 allowed: [ 'aria-valuetext', 'aria-orientation', 'aria-readonly', 'aria-errormessage', 'aria-valuemax', 'aria-valuemin' ], -1 21439 required: [ 'aria-valuenow' ] -1 21440 }, -1 21441 owned: null, -1 21442 nameFrom: [ 'author' ], -1 21443 context: null, -1 21444 implicit: [ 'input[type="range"]' ], -1 21445 unsupported: false -1 21446 }, -1 21447 spinbutton: { -1 21448 type: 'widget', -1 21449 attributes: { -1 21450 allowed: [ 'aria-valuetext', 'aria-required', 'aria-readonly', 'aria-errormessage', 'aria-valuemax', 'aria-valuemin' ], -1 21451 required: [ 'aria-valuenow' ] -1 21452 }, -1 21453 owned: null, -1 21454 nameFrom: [ 'author' ], -1 21455 context: null, -1 21456 implicit: [ 'input[type="number"]' ], -1 21457 unsupported: false, -1 21458 allowedElements: { -1 21459 nodeName: 'input', -1 21460 properties: { -1 21461 type: [ 'text', 'tel' ] -1 21462 } -1 21463 } -1 21464 }, -1 21465 status: { -1 21466 type: 'widget', -1 21467 attributes: { -1 21468 allowed: [ 'aria-expanded', 'aria-errormessage' ] -1 21469 }, -1 21470 owned: null, -1 21471 nameFrom: [ 'author' ], -1 21472 context: null, -1 21473 implicit: [ 'output' ], -1 21474 unsupported: false, -1 21475 allowedElements: [ 'section' ] -1 21476 }, -1 21477 structure: { -1 21478 type: 'abstract', -1 21479 unsupported: false -1 21480 }, -1 21481 switch: { -1 21482 type: 'widget', -1 21483 attributes: { -1 21484 allowed: [ 'aria-errormessage' ], -1 21485 required: [ 'aria-checked' ] -1 21486 }, -1 21487 owned: null, -1 21488 nameFrom: [ 'author', 'contents' ], -1 21489 context: null, -1 21490 unsupported: false, -1 21491 allowedElements: [ 'button', { -1 21492 nodeName: 'input', -1 21493 properties: { -1 21494 type: [ 'checkbox', 'image', 'button' ] -1 21495 } -1 21496 }, { -1 21497 nodeName: 'a', -1 21498 attributes: { -1 21499 href: isNotNull -1 21500 } -1 21501 } ] -1 21502 }, -1 21503 tab: { -1 21504 type: 'widget', -1 21505 attributes: { -1 21506 allowed: [ 'aria-selected', 'aria-expanded', 'aria-setsize', 'aria-posinset', 'aria-errormessage' ] -1 21507 }, -1 21508 owned: null, -1 21509 nameFrom: [ 'author', 'contents' ], -1 21510 context: [ 'tablist' ], -1 21511 unsupported: false, -1 21512 allowedElements: [ { -1 21513 nodeName: [ 'button', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li' ] -1 21514 }, { -1 21515 nodeName: 'input', -1 21516 properties: { -1 21517 type: 'button' -1 21518 } -1 21519 }, { -1 21520 nodeName: 'a', -1 21521 attributes: { -1 21522 href: isNotNull -1 21523 } -1 21524 } ] -1 21525 }, -1 21526 table: { -1 21527 type: 'structure', -1 21528 attributes: { -1 21529 allowed: [ 'aria-colcount', 'aria-rowcount', 'aria-errormessage' ] -1 21530 }, -1 21531 owned: { -1 21532 one: [ 'rowgroup', 'row' ] -1 21533 }, -1 21534 nameFrom: [ 'author', 'contents' ], -1 21535 context: null, -1 21536 implicit: [ 'table' ], -1 21537 unsupported: false -1 21538 }, -1 21539 tablist: { -1 21540 type: 'composite', -1 21541 attributes: { -1 21542 allowed: [ 'aria-activedescendant', 'aria-expanded', 'aria-level', 'aria-multiselectable', 'aria-orientation', 'aria-errormessage' ] -1 21543 }, -1 21544 owned: { -1 21545 all: [ 'tab' ] -1 21546 }, -1 21547 nameFrom: [ 'author' ], -1 21548 context: null, -1 21549 unsupported: false, -1 21550 allowedElements: [ 'ol', 'ul' ] -1 21551 }, -1 21552 tabpanel: { -1 21553 type: 'widget', -1 21554 attributes: { -1 21555 allowed: [ 'aria-expanded', 'aria-errormessage' ] -1 21556 }, -1 21557 owned: null, -1 21558 nameFrom: [ 'author' ], -1 21559 context: null, -1 21560 unsupported: false, -1 21561 allowedElements: [ 'section' ] -1 21562 }, -1 21563 term: { -1 21564 type: 'structure', -1 21565 attributes: { -1 21566 allowed: [ 'aria-expanded', 'aria-errormessage' ] -1 21567 }, -1 21568 owned: null, -1 21569 nameFrom: [ 'author', 'contents' ], -1 21570 context: null, -1 21571 implicit: [ 'dt' ], -1 21572 unsupported: false -1 21573 }, -1 21574 textbox: { -1 21575 type: 'widget', -1 21576 attributes: { -1 21577 allowed: [ 'aria-activedescendant', 'aria-autocomplete', 'aria-multiline', 'aria-readonly', 'aria-required', 'aria-placeholder', 'aria-errormessage' ] -1 21578 }, -1 21579 owned: null, -1 21580 nameFrom: [ 'author' ], -1 21581 context: null, -1 21582 implicit: [ 'input[type="text"]', 'input[type="email"]', 'input[type="password"]', 'input[type="tel"]', 'input[type="url"]', 'input:not([type])', 'textarea' ], -1 21583 unsupported: false -1 21584 }, -1 21585 timer: { -1 21586 type: 'widget', -1 21587 attributes: { -1 21588 allowed: [ 'aria-expanded', 'aria-errormessage' ] -1 21589 }, -1 21590 owned: null, -1 21591 nameFrom: [ 'author' ], -1 21592 context: null, -1 21593 unsupported: false -1 21594 }, -1 21595 toolbar: { -1 21596 type: 'structure', -1 21597 attributes: { -1 21598 allowed: [ 'aria-activedescendant', 'aria-expanded', 'aria-orientation', 'aria-errormessage' ] -1 21599 }, -1 21600 owned: null, -1 21601 nameFrom: [ 'author' ], -1 21602 context: null, -1 21603 implicit: [ 'menu[type="toolbar"]' ], -1 21604 unsupported: false, -1 21605 allowedElements: [ 'ol', 'ul' ] -1 21606 }, -1 21607 tooltip: { -1 21608 type: 'structure', -1 21609 attributes: { -1 21610 allowed: [ 'aria-expanded', 'aria-errormessage' ] 47313 21611 }, 47314 21612 owned: null, 47315 21613 nameFrom: [ 'author', 'contents' ],47316 -1 context: [ 'row' ],47317 -1 implicit: [ 'th' ],-1 21614 context: null, 47318 21615 unsupported: false 47319 21616 },47320 -1 scrollbar: {47321 -1 type: 'widget',-1 21617 tree: { -1 21618 type: 'composite', 47322 21619 attributes: {47323 -1 required: [ 'aria-controls', 'aria-valuenow' ],47324 -1 allowed: [ 'aria-valuetext', 'aria-orientation', 'aria-errormessage', 'aria-valuemax', 'aria-valuemin' ]-1 21620 allowed: [ 'aria-activedescendant', 'aria-multiselectable', 'aria-required', 'aria-expanded', 'aria-orientation', 'aria-errormessage' ] -1 21621 }, -1 21622 owned: { -1 21623 all: [ 'treeitem' ] 47325 21624 },47326 -1 owned: null,47327 21625 nameFrom: [ 'author' ], 47328 21626 context: null,47329 -1 unsupported: false-1 21627 unsupported: false, -1 21628 allowedElements: [ 'ol', 'ul' ] 47330 21629 },47331 -1 search: {47332 -1 type: 'landmark',-1 21630 treegrid: { -1 21631 type: 'composite', 47333 21632 attributes: {47334 -1 allowed: [ 'aria-expanded', 'aria-errormessage' ]-1 21633 allowed: [ 'aria-activedescendant', 'aria-colcount', 'aria-expanded', 'aria-level', 'aria-multiselectable', 'aria-readonly', 'aria-required', 'aria-rowcount', 'aria-orientation', 'aria-errormessage' ] -1 21634 }, -1 21635 owned: { -1 21636 one: [ 'rowgroup', 'row' ] 47335 21637 },47336 -1 owned: null,47337 21638 nameFrom: [ 'author' ], 47338 21639 context: null,47339 -1 unsupported: false,47340 -1 allowedElements: {47341 -1 nodeName: [ 'aside', 'form', 'section' ]47342 -1 }-1 21640 unsupported: false 47343 21641 },47344 -1 searchbox: {-1 21642 treeitem: { 47345 21643 type: 'widget', 47346 21644 attributes: {47347 -1 allowed: [ 'aria-activedescendant', 'aria-autocomplete', 'aria-multiline', 'aria-readonly', 'aria-required', 'aria-placeholder', 'aria-errormessage' ]-1 21645 allowed: [ 'aria-checked', 'aria-selected', 'aria-expanded', 'aria-level', 'aria-posinset', 'aria-setsize', 'aria-errormessage' ] 47348 21646 }, 47349 21647 owned: null,47350 -1 nameFrom: [ 'author' ],47351 -1 context: null,47352 -1 implicit: [ 'input[type="search"]' ],-1 21648 nameFrom: [ 'author', 'contents' ], -1 21649 context: [ 'group', 'tree' ], 47353 21650 unsupported: false,47354 -1 allowedElements: {47355 -1 nodeName: 'input',47356 -1 properties: {47357 -1 type: 'text'-1 21651 allowedElements: [ 'li', { -1 21652 nodeName: 'a', -1 21653 attributes: { -1 21654 href: isNotNull -1 21655 } -1 21656 } ] -1 21657 }, -1 21658 widget: { -1 21659 type: 'abstract', -1 21660 unsupported: false -1 21661 }, -1 21662 window: { -1 21663 nameFrom: [ 'author' ], -1 21664 type: 'abstract', -1 21665 unsupported: false -1 21666 } -1 21667 }; -1 21668 lookupTable.implicitHtmlRole = implicit_html_roles_default; -1 21669 lookupTable.elementsAllowedNoRole = [ { -1 21670 nodeName: [ 'base', 'body', 'caption', 'col', 'colgroup', 'datalist', 'dd', 'details', 'dt', 'head', 'html', 'keygen', 'label', 'legend', 'main', 'map', 'math', 'meta', 'meter', 'noscript', 'optgroup', 'param', 'picture', 'progress', 'script', 'source', 'style', 'template', 'textarea', 'title', 'track' ] -1 21671 }, { -1 21672 nodeName: 'area', -1 21673 attributes: { -1 21674 href: isNotNull -1 21675 } -1 21676 }, { -1 21677 nodeName: 'input', -1 21678 properties: { -1 21679 type: [ 'color', 'data', 'datatime', 'file', 'hidden', 'month', 'number', 'password', 'range', 'reset', 'submit', 'time', 'week' ] -1 21680 } -1 21681 }, { -1 21682 nodeName: 'link', -1 21683 attributes: { -1 21684 href: isNotNull -1 21685 } -1 21686 }, { -1 21687 nodeName: 'menu', -1 21688 attributes: { -1 21689 type: 'context' -1 21690 } -1 21691 }, { -1 21692 nodeName: 'menuitem', -1 21693 attributes: { -1 21694 type: [ 'command', 'checkbox', 'radio' ] -1 21695 } -1 21696 }, { -1 21697 nodeName: 'select', -1 21698 condition: function condition(vNode) { -1 21699 if (!(vNode instanceof axe.AbstractVirtualNode)) { -1 21700 vNode = axe.utils.getNodeFromTree(vNode); -1 21701 } -1 21702 return Number(vNode.attr('size')) > 1; -1 21703 }, -1 21704 properties: { -1 21705 multiple: true -1 21706 } -1 21707 }, { -1 21708 nodeName: [ 'clippath', 'cursor', 'defs', 'desc', 'feblend', 'fecolormatrix', 'fecomponenttransfer', 'fecomposite', 'feconvolvematrix', 'fediffuselighting', 'fedisplacementmap', 'fedistantlight', 'fedropshadow', 'feflood', 'fefunca', 'fefuncb', 'fefuncg', 'fefuncr', 'fegaussianblur', 'feimage', 'femerge', 'femergenode', 'femorphology', 'feoffset', 'fepointlight', 'fespecularlighting', 'fespotlight', 'fetile', 'feturbulence', 'filter', 'hatch', 'hatchpath', 'lineargradient', 'marker', 'mask', 'meshgradient', 'meshpatch', 'meshrow', 'metadata', 'mpath', 'pattern', 'radialgradient', 'solidcolor', 'stop', 'switch', 'view' ] -1 21709 } ]; -1 21710 lookupTable.elementsAllowedAnyRole = [ { -1 21711 nodeName: 'a', -1 21712 attributes: { -1 21713 href: isNull -1 21714 } -1 21715 }, { -1 21716 nodeName: 'img', -1 21717 attributes: { -1 21718 alt: isNull -1 21719 } -1 21720 }, { -1 21721 nodeName: [ 'abbr', 'address', 'canvas', 'div', 'p', 'pre', 'blockquote', 'ins', 'del', 'output', 'span', 'table', 'tbody', 'thead', 'tfoot', 'td', 'em', 'strong', 'small', 's', 'cite', 'q', 'dfn', 'abbr', 'time', 'code', 'var', 'samp', 'kbd', 'sub', 'sup', 'i', 'b', 'u', 'mark', 'ruby', 'rt', 'rp', 'bdi', 'bdo', 'br', 'wbr', 'th', 'tr' ] -1 21722 } ]; -1 21723 lookupTable.evaluateRoleForElement = { -1 21724 A: function A(_ref45) { -1 21725 var node = _ref45.node, out = _ref45.out; -1 21726 if (node.namespaceURI === 'http://www.w3.org/2000/svg') { -1 21727 return true; -1 21728 } -1 21729 if (node.href.length) { -1 21730 return out; -1 21731 } -1 21732 return true; -1 21733 }, -1 21734 AREA: function AREA(_ref46) { -1 21735 var node = _ref46.node; -1 21736 return !node.href; -1 21737 }, -1 21738 BUTTON: function BUTTON(_ref47) { -1 21739 var node = _ref47.node, role = _ref47.role, out = _ref47.out; -1 21740 if (node.getAttribute('type') === 'menu') { -1 21741 return role === 'menuitem'; -1 21742 } -1 21743 return out; -1 21744 }, -1 21745 IMG: function IMG(_ref48) { -1 21746 var node = _ref48.node, role = _ref48.role, out = _ref48.out; -1 21747 switch (node.alt) { -1 21748 case null: -1 21749 return out; -1 21750 -1 21751 case '': -1 21752 return role === 'presentation' || role === 'none'; -1 21753 -1 21754 default: -1 21755 return role !== 'presentation' && role !== 'none'; -1 21756 } -1 21757 }, -1 21758 INPUT: function INPUT(_ref49) { -1 21759 var node = _ref49.node, role = _ref49.role, out = _ref49.out; -1 21760 switch (node.type) { -1 21761 case 'button': -1 21762 case 'image': -1 21763 return out; -1 21764 -1 21765 case 'checkbox': -1 21766 if (role === 'button' && node.hasAttribute('aria-pressed')) { -1 21767 return true; -1 21768 } -1 21769 return out; -1 21770 -1 21771 case 'radio': -1 21772 return role === 'menuitemradio'; -1 21773 -1 21774 case 'text': -1 21775 return role === 'combobox' || role === 'searchbox' || role === 'spinbutton'; -1 21776 -1 21777 case 'tel': -1 21778 return role === 'combobox' || role === 'spinbutton'; -1 21779 -1 21780 case 'url': -1 21781 case 'search': -1 21782 case 'email': -1 21783 return role === 'combobox'; -1 21784 -1 21785 default: -1 21786 return false; -1 21787 } -1 21788 }, -1 21789 LI: function LI(_ref50) { -1 21790 var node = _ref50.node, out = _ref50.out; -1 21791 var hasImplicitListitemRole = axe.utils.matchesSelector(node, 'ol li, ul li'); -1 21792 if (hasImplicitListitemRole) { -1 21793 return out; -1 21794 } -1 21795 return true; -1 21796 }, -1 21797 MENU: function MENU(_ref51) { -1 21798 var node = _ref51.node; -1 21799 if (node.getAttribute('type') === 'context') { -1 21800 return false; -1 21801 } -1 21802 return true; -1 21803 }, -1 21804 OPTION: function OPTION(_ref52) { -1 21805 var node = _ref52.node; -1 21806 var withinOptionList = axe.utils.matchesSelector(node, 'select > option, datalist > option, optgroup > option'); -1 21807 return !withinOptionList; -1 21808 }, -1 21809 SELECT: function SELECT(_ref53) { -1 21810 var node = _ref53.node, role = _ref53.role; -1 21811 return !node.multiple && node.size <= 1 && role === 'menu'; -1 21812 }, -1 21813 SVG: function SVG(_ref54) { -1 21814 var node = _ref54.node, out = _ref54.out; -1 21815 if (node.parentNode && node.parentNode.namespaceURI === 'http://www.w3.org/2000/svg') { -1 21816 return true; -1 21817 } -1 21818 return out; -1 21819 } -1 21820 }; -1 21821 lookupTable.rolesOfType = { -1 21822 widget: [ 'button', 'checkbox', 'dialog', 'gridcell', 'link', 'log', 'marquee', 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'option', 'progressbar', 'radio', 'scrollbar', 'searchbox', 'slider', 'spinbutton', 'status', 'switch', 'tab', 'tabpanel', 'textbox', 'timer', 'tooltip', 'tree', 'treeitem' ] -1 21823 }; -1 21824 var lookup_table_default = lookupTable; -1 21825 function implicitNodes(role) { -1 21826 var implicit = null; -1 21827 var roles = lookup_table_default.role[role]; -1 21828 if (roles && roles.implicit) { -1 21829 implicit = clone_default(roles.implicit); -1 21830 } -1 21831 return implicit; -1 21832 } -1 21833 var implicit_nodes_default = implicitNodes; -1 21834 function isAccessibleRef(node) { -1 21835 return !!get_accessible_refs_default(node).length; -1 21836 } -1 21837 var is_accessible_ref_default = isAccessibleRef; -1 21838 function label3(node) { -1 21839 node = get_node_from_tree_default(node); -1 21840 return label_virtual_default(node); -1 21841 } -1 21842 var label_default2 = label3; -1 21843 function requiredAttr(role) { -1 21844 var roleDef = standards_default.ariaRoles[role]; -1 21845 if (!roleDef || !Array.isArray(roleDef.requiredAttrs)) { -1 21846 return []; -1 21847 } -1 21848 return _toConsumableArray(roleDef.requiredAttrs); -1 21849 } -1 21850 var required_attr_default = requiredAttr; -1 21851 function requiredContext(role) { -1 21852 var roleDef = standards_default.ariaRoles[role]; -1 21853 if (!roleDef || !Array.isArray(roleDef.requiredContext)) { -1 21854 return null; -1 21855 } -1 21856 return _toConsumableArray(roleDef.requiredContext); -1 21857 } -1 21858 var required_context_default = requiredContext; -1 21859 function requiredOwned(role) { -1 21860 var roleDef = standards_default.ariaRoles[role]; -1 21861 if (!roleDef || !Array.isArray(roleDef.requiredOwned)) { -1 21862 return null; -1 21863 } -1 21864 return _toConsumableArray(roleDef.requiredOwned); -1 21865 } -1 21866 var required_owned_default = requiredOwned; -1 21867 function validateAttrValue(vNode, attr) { -1 21868 vNode = vNode instanceof abstract_virtual_node_default ? vNode : get_node_from_tree_default(vNode); -1 21869 var matches14; -1 21870 var list; -1 21871 var value = vNode.attr(attr); -1 21872 var attrInfo = standards_default.ariaAttrs[attr]; -1 21873 if (!attrInfo) { -1 21874 return true; -1 21875 } -1 21876 if (attrInfo.allowEmpty && (!value || value.trim() === '')) { -1 21877 return true; -1 21878 } -1 21879 switch (attrInfo.type) { -1 21880 case 'boolean': -1 21881 return [ 'true', 'false' ].includes(value.toLowerCase()); -1 21882 -1 21883 case 'nmtoken': -1 21884 return typeof value === 'string' && attrInfo.values.includes(value.toLowerCase()); -1 21885 -1 21886 case 'nmtokens': -1 21887 list = token_list_default(value); -1 21888 return list.reduce(function(result, token) { -1 21889 return result && attrInfo.values.includes(token); -1 21890 }, list.length !== 0); -1 21891 -1 21892 case 'idref': -1 21893 try { -1 21894 var doc = get_root_node_default2(vNode.actualNode); -1 21895 return !!(value && doc.getElementById(value)); -1 21896 } catch (e) { -1 21897 throw new TypeError('Cannot resolve id references for partial DOM'); -1 21898 } -1 21899 -1 21900 case 'idrefs': -1 21901 return idrefs_default(vNode, attr).some(function(node) { -1 21902 return !!node; -1 21903 }); -1 21904 -1 21905 case 'string': -1 21906 return value.trim() !== ''; -1 21907 -1 21908 case 'decimal': -1 21909 matches14 = value.match(/^[-+]?([0-9]*)\.?([0-9]*)$/); -1 21910 return !!(matches14 && (matches14[1] || matches14[2])); -1 21911 -1 21912 case 'int': -1 21913 var minValue = typeof attrInfo.minValue !== 'undefined' ? attrInfo.minValue : -Infinity; -1 21914 return /^[-+]?[0-9]+$/.test(value) && parseInt(value) >= minValue; -1 21915 } -1 21916 } -1 21917 var validate_attr_value_default = validateAttrValue; -1 21918 function validateAttr(att) { -1 21919 var attrDefinition = standards_default.ariaAttrs[att]; -1 21920 return !!attrDefinition; -1 21921 } -1 21922 var validate_attr_default = validateAttr; -1 21923 function abstractroleEvaluate(node, options, virtualNode) { -1 21924 var abstractRoles = token_list_default(virtualNode.attr('role')).filter(function(role) { -1 21925 return get_role_type_default(role) === 'abstract'; -1 21926 }); -1 21927 if (abstractRoles.length > 0) { -1 21928 this.data(abstractRoles); -1 21929 return true; -1 21930 } -1 21931 return false; -1 21932 } -1 21933 var abstractrole_evaluate_default = abstractroleEvaluate; -1 21934 function ariaAllowedAttrEvaluate(node, options, virtualNode) { -1 21935 var invalid = []; -1 21936 var role = get_role_default(virtualNode); -1 21937 var attrs = virtualNode.attrNames; -1 21938 var allowed = allowed_attr_default(role); -1 21939 if (Array.isArray(options[role])) { -1 21940 allowed = unique_array_default(options[role].concat(allowed)); -1 21941 } -1 21942 var tableMap = cache_default.get('aria-allowed-attr-table'); -1 21943 if (!tableMap) { -1 21944 tableMap = new WeakMap(); -1 21945 cache_default.set('aria-allowed-attr-table', tableMap); -1 21946 } -1 21947 function validateRowAttrs() { -1 21948 if (virtualNode.parent && role === 'row') { -1 21949 var table5 = closest_default(virtualNode, 'table, [role="treegrid"], [role="table"], [role="grid"]'); -1 21950 var tableRole = tableMap.get(table5); -1 21951 if (table5 && !tableRole) { -1 21952 tableRole = get_role_default(table5); -1 21953 tableMap.set(table5, tableRole); -1 21954 } -1 21955 if ([ 'table', 'grid' ].includes(tableRole) && role === 'row') { -1 21956 return true; -1 21957 } -1 21958 } -1 21959 } -1 21960 var ariaAttr = Array.isArray(options.validTreeRowAttrs) ? options.validTreeRowAttrs : []; -1 21961 var preChecks = {}; -1 21962 ariaAttr.forEach(function(attr) { -1 21963 preChecks[attr] = validateRowAttrs; -1 21964 }); -1 21965 if (allowed) { -1 21966 for (var _i15 = 0; _i15 < attrs.length; _i15++) { -1 21967 var _preChecks$attrName; -1 21968 var attrName = attrs[_i15]; -1 21969 if (validate_attr_default(attrName) && (_preChecks$attrName = preChecks[attrName]) !== null && _preChecks$attrName !== void 0 && _preChecks$attrName.call(preChecks)) { -1 21970 invalid.push(attrName + '="' + virtualNode.attr(attrName) + '"'); -1 21971 } else if (validate_attr_default(attrName) && !allowed.includes(attrName)) { -1 21972 invalid.push(attrName + '="' + virtualNode.attr(attrName) + '"'); -1 21973 } -1 21974 } -1 21975 } -1 21976 if (invalid.length) { -1 21977 this.data(invalid); -1 21978 if (!is_html_element_default(virtualNode) && !role && !is_focusable_default(virtualNode)) { -1 21979 return void 0; -1 21980 } -1 21981 return false; -1 21982 } -1 21983 return true; -1 21984 } -1 21985 var aria_allowed_attr_evaluate_default = ariaAllowedAttrEvaluate; -1 21986 function ariaAllowedRoleEvaluate(node) { -1 21987 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; -1 21988 var virtualNode = arguments.length > 2 ? arguments[2] : undefined; -1 21989 var _options$allowImplici = options.allowImplicit, allowImplicit = _options$allowImplici === void 0 ? true : _options$allowImplici, _options$ignoredTags = options.ignoredTags, ignoredTags = _options$ignoredTags === void 0 ? [] : _options$ignoredTags; -1 21990 var nodeName2 = virtualNode.props.nodeName; -1 21991 if (ignoredTags.map(function(tag) { -1 21992 return tag.toLowerCase(); -1 21993 }).includes(nodeName2)) { -1 21994 return true; -1 21995 } -1 21996 var unallowedRoles = get_element_unallowed_roles_default(virtualNode, allowImplicit); -1 21997 if (unallowedRoles.length) { -1 21998 this.data(unallowedRoles); -1 21999 if (!is_visible_default(virtualNode, true)) { -1 22000 return void 0; -1 22001 } -1 22002 return false; -1 22003 } -1 22004 return true; -1 22005 } -1 22006 var aria_allowed_role_evaluate_default = ariaAllowedRoleEvaluate; -1 22007 function ariaErrormessageEvaluate(node, options, virtualNode) { -1 22008 options = Array.isArray(options) ? options : []; -1 22009 var attr = virtualNode.attr('aria-errormessage'); -1 22010 var hasAttr = virtualNode.hasAttr('aria-errormessage'); -1 22011 var invaid = virtualNode.attr('aria-invalid'); -1 22012 var hasInvallid = virtualNode.hasAttr('aria-invalid'); -1 22013 if (!hasInvallid || invaid === 'false') { -1 22014 return true; -1 22015 } -1 22016 function validateAttrValue2(attr2) { -1 22017 if (attr2.trim() === '') { -1 22018 return standards_default.ariaAttrs['aria-errormessage'].allowEmpty; -1 22019 } -1 22020 var idref; -1 22021 try { -1 22022 idref = attr2 && idrefs_default(virtualNode, 'aria-errormessage')[0]; -1 22023 } catch (e) { -1 22024 this.data({ -1 22025 messageKey: 'idrefs', -1 22026 values: token_list_default(attr2) -1 22027 }); -1 22028 return void 0; -1 22029 } -1 22030 if (idref) { -1 22031 if (!is_visible_default(idref, true)) { -1 22032 this.data({ -1 22033 messageKey: 'hidden', -1 22034 values: token_list_default(attr2) -1 22035 }); -1 22036 return false; -1 22037 } -1 22038 return idref.getAttribute('role') === 'alert' || idref.getAttribute('aria-live') === 'assertive' || idref.getAttribute('aria-live') === 'polite' || token_list_default(virtualNode.attr('aria-describedby')).indexOf(attr2) > -1; -1 22039 } -1 22040 return; -1 22041 } -1 22042 if (options.indexOf(attr) === -1 && hasAttr) { -1 22043 this.data(token_list_default(attr)); -1 22044 return validateAttrValue2.call(this, attr); -1 22045 } -1 22046 return true; -1 22047 } -1 22048 var aria_errormessage_evaluate_default = ariaErrormessageEvaluate; -1 22049 function ariaHiddenBodyEvaluate(node, options, virtualNode) { -1 22050 return virtualNode.attr('aria-hidden') !== 'true'; -1 22051 } -1 22052 var aria_hidden_body_evaluate_default = ariaHiddenBodyEvaluate; -1 22053 function ariaLevelEvaluate(node, options, virtualNode) { -1 22054 var ariaHeadingLevel = virtualNode.attr('aria-level'); -1 22055 var ariaLevel = parseInt(ariaHeadingLevel, 10); -1 22056 if (ariaLevel > 6) { -1 22057 return void 0; -1 22058 } -1 22059 return true; -1 22060 } -1 22061 var aria_level_evaluate_default = ariaLevelEvaluate; -1 22062 function ariaProhibitedAttrEvaluate(node) { -1 22063 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; -1 22064 var virtualNode = arguments.length > 2 ? arguments[2] : undefined; -1 22065 var elementsAllowedAriaLabel = (options === null || options === void 0 ? void 0 : options.elementsAllowedAriaLabel) || []; -1 22066 var nodeName2 = virtualNode.props.nodeName; -1 22067 var role = get_role_default(virtualNode, { -1 22068 chromium: true -1 22069 }); -1 22070 var prohibitedList = listProhibitedAttrs(role, nodeName2, elementsAllowedAriaLabel); -1 22071 var prohibited = prohibitedList.filter(function(attrName) { -1 22072 if (!virtualNode.attrNames.includes(attrName)) { -1 22073 return false; -1 22074 } -1 22075 return sanitize_default(virtualNode.attr(attrName)) !== ''; -1 22076 }); -1 22077 if (prohibited.length === 0) { -1 22078 return false; -1 22079 } -1 22080 var messageKey = virtualNode.hasAttr('role') ? 'hasRole' : 'noRole'; -1 22081 messageKey += prohibited.length > 1 ? 'Plural' : 'Singular'; -1 22082 this.data({ -1 22083 role: role, -1 22084 nodeName: nodeName2, -1 22085 messageKey: messageKey, -1 22086 prohibited: prohibited -1 22087 }); -1 22088 var textContent = subtree_text_default(virtualNode, { -1 22089 subtreeDescendant: true -1 22090 }); -1 22091 if (sanitize_default(textContent) !== '') { -1 22092 return void 0; -1 22093 } -1 22094 return true; -1 22095 } -1 22096 function listProhibitedAttrs(role, nodeName2, elementsAllowedAriaLabel) { -1 22097 var roleSpec = standards_default.ariaRoles[role]; -1 22098 if (roleSpec) { -1 22099 return roleSpec.prohibitedAttrs || []; -1 22100 } -1 22101 if (!!role || elementsAllowedAriaLabel.includes(nodeName2)) { -1 22102 return []; -1 22103 } -1 22104 return [ 'aria-label', 'aria-labelledby' ]; -1 22105 } -1 22106 var standards_exports = {}; -1 22107 __export(standards_exports, { -1 22108 getAriaRolesByType: function getAriaRolesByType() { -1 22109 return get_aria_roles_by_type_default; -1 22110 }, -1 22111 getAriaRolesSupportingNameFromContent: function getAriaRolesSupportingNameFromContent() { -1 22112 return get_aria_roles_supporting_name_from_content_default; -1 22113 }, -1 22114 getElementSpec: function getElementSpec() { -1 22115 return get_element_spec_default; -1 22116 }, -1 22117 getElementsByContentType: function getElementsByContentType() { -1 22118 return get_elements_by_content_type_default; -1 22119 }, -1 22120 getGlobalAriaAttrs: function getGlobalAriaAttrs() { -1 22121 return get_global_aria_attrs_default; -1 22122 }, -1 22123 implicitHtmlRoles: function implicitHtmlRoles() { -1 22124 return implicit_html_roles_default; -1 22125 } -1 22126 }); -1 22127 function ariaRequiredAttrEvaluate(node) { -1 22128 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; -1 22129 var virtualNode = arguments.length > 2 ? arguments[2] : undefined; -1 22130 var missing = []; -1 22131 var attrs = virtualNode.attrNames; -1 22132 var role = get_explicit_role_default(virtualNode); -1 22133 if (attrs.length) { -1 22134 var required = required_attr_default(role); -1 22135 var elmSpec = get_element_spec_default(virtualNode); -1 22136 if (Array.isArray(options[role])) { -1 22137 required = unique_array_default(options[role], required); -1 22138 } -1 22139 if (role && required) { -1 22140 for (var _i16 = 0, l = required.length; _i16 < l; _i16++) { -1 22141 var attr = required[_i16]; -1 22142 if (!virtualNode.attr(attr) && !(elmSpec.implicitAttrs && typeof elmSpec.implicitAttrs[attr] !== 'undefined')) { -1 22143 missing.push(attr); -1 22144 } -1 22145 } -1 22146 } -1 22147 } -1 22148 var comboboxMissingControls = role === 'combobox' && missing.includes('aria-controls'); -1 22149 if (comboboxMissingControls && (virtualNode.hasAttr('aria-owns') || virtualNode.attr('aria-expanded') !== 'true')) { -1 22150 missing.splice(missing.indexOf('aria-controls', 1)); -1 22151 } -1 22152 if (missing.length) { -1 22153 this.data(missing); -1 22154 return false; -1 22155 } -1 22156 return true; -1 22157 } -1 22158 var aria_required_attr_evaluate_default = ariaRequiredAttrEvaluate; -1 22159 function getOwnedRoles(virtualNode, required) { -1 22160 var ownedRoles = []; -1 22161 var ownedElements = get_owned_virtual_default(virtualNode); -1 22162 var _loop4 = function _loop4(_i17) { -1 22163 var ownedElement = ownedElements[_i17]; -1 22164 var role = get_role_default(ownedElement, { -1 22165 noPresentational: true -1 22166 }); -1 22167 if (!role || [ 'group', 'rowgroup' ].includes(role) && required.some(function(requiredRole) { -1 22168 return requiredRole === role; -1 22169 })) { -1 22170 ownedElements.push.apply(ownedElements, _toConsumableArray(ownedElement.children)); -1 22171 } else if (role) { -1 22172 ownedRoles.push(role); -1 22173 } -1 22174 }; -1 22175 for (var _i17 = 0; _i17 < ownedElements.length; _i17++) { -1 22176 _loop4(_i17); -1 22177 } -1 22178 return ownedRoles; -1 22179 } -1 22180 function missingRequiredChildren(virtualNode, role, required, ownedRoles) { -1 22181 for (var _i18 = 0; _i18 < ownedRoles.length; _i18++) { -1 22182 var ownedRole = ownedRoles[_i18]; -1 22183 if (required.includes(ownedRole)) { -1 22184 required = required.filter(function(requiredRole) { -1 22185 return requiredRole !== ownedRole; -1 22186 }); -1 22187 return null; -1 22188 } -1 22189 } -1 22190 if (required.length) { -1 22191 return required; -1 22192 } -1 22193 return null; -1 22194 } -1 22195 function ariaRequiredChildrenEvaluate(node, options, virtualNode) { -1 22196 var reviewEmpty = options && Array.isArray(options.reviewEmpty) ? options.reviewEmpty : []; -1 22197 var role = get_explicit_role_default(virtualNode, { -1 22198 dpub: true -1 22199 }); -1 22200 var required = required_owned_default(role); -1 22201 if (required === null) { -1 22202 return true; -1 22203 } -1 22204 var ownedRoles = getOwnedRoles(virtualNode, required); -1 22205 var missing = missingRequiredChildren(virtualNode, role, required, ownedRoles); -1 22206 if (!missing) { -1 22207 return true; -1 22208 } -1 22209 this.data(missing); -1 22210 if (reviewEmpty.includes(role) && !has_content_virtual_default(virtualNode, false, true) && !ownedRoles.length && (!virtualNode.hasAttr('aria-owns') || !idrefs_default(node, 'aria-owns').length)) { -1 22211 return void 0; -1 22212 } -1 22213 return false; -1 22214 } -1 22215 var aria_required_children_evaluate_default = ariaRequiredChildrenEvaluate; -1 22216 function getMissingContext(virtualNode, ownGroupRoles, reqContext, includeElement) { -1 22217 var explicitRole2 = get_explicit_role_default(virtualNode); -1 22218 if (!reqContext) { -1 22219 reqContext = required_context_default(explicitRole2); -1 22220 } -1 22221 if (!reqContext) { -1 22222 return null; -1 22223 } -1 22224 var vNode = includeElement ? virtualNode : virtualNode.parent; -1 22225 while (vNode) { -1 22226 var parentRole = get_role_default(vNode); -1 22227 if (reqContext.includes('group') && parentRole === 'group') { -1 22228 if (ownGroupRoles.includes(explicitRole2)) { -1 22229 reqContext.push(explicitRole2); 47358 22230 } -1 22231 reqContext = reqContext.filter(function(r) { -1 22232 return r !== 'group'; -1 22233 }); -1 22234 vNode = vNode.parent; -1 22235 continue; 47359 22236 }47360 -1 },47361 -1 section: {47362 -1 nameFrom: [ 'author', 'contents' ],47363 -1 type: 'abstract',47364 -1 unsupported: false47365 -1 },47366 -1 sectionhead: {47367 -1 nameFrom: [ 'author', 'contents' ],47368 -1 type: 'abstract',47369 -1 unsupported: false47370 -1 },47371 -1 select: {47372 -1 nameFrom: [ 'author' ],47373 -1 type: 'abstract',47374 -1 unsupported: false47375 -1 },47376 -1 separator: {47377 -1 type: 'structure',47378 -1 attributes: {47379 -1 allowed: [ 'aria-expanded', 'aria-orientation', 'aria-valuenow', 'aria-valuemax', 'aria-valuemin', 'aria-valuetext', 'aria-errormessage' ]47380 -1 },47381 -1 owned: null,47382 -1 nameFrom: [ 'author' ],47383 -1 context: null,47384 -1 implicit: [ 'hr' ],47385 -1 unsupported: false,47386 -1 allowedElements: [ 'li' ]47387 -1 },47388 -1 slider: {47389 -1 type: 'widget',47390 -1 attributes: {47391 -1 allowed: [ 'aria-valuetext', 'aria-orientation', 'aria-readonly', 'aria-errormessage', 'aria-valuemax', 'aria-valuemin' ],47392 -1 required: [ 'aria-valuenow' ]47393 -1 },47394 -1 owned: null,47395 -1 nameFrom: [ 'author' ],47396 -1 context: null,47397 -1 implicit: [ 'input[type="range"]' ],47398 -1 unsupported: false47399 -1 },47400 -1 spinbutton: {47401 -1 type: 'widget',47402 -1 attributes: {47403 -1 allowed: [ 'aria-valuetext', 'aria-required', 'aria-readonly', 'aria-errormessage', 'aria-valuemax', 'aria-valuemin' ],47404 -1 required: [ 'aria-valuenow' ]47405 -1 },47406 -1 owned: null,47407 -1 nameFrom: [ 'author' ],47408 -1 context: null,47409 -1 implicit: [ 'input[type="number"]' ],47410 -1 unsupported: false,47411 -1 allowedElements: {47412 -1 nodeName: 'input',47413 -1 properties: {47414 -1 type: [ 'text', 'tel' ]47415 -1 }-1 22237 if (reqContext.includes(parentRole)) { -1 22238 return null; -1 22239 } else if (parentRole && ![ 'presentation', 'none' ].includes(parentRole)) { -1 22240 return reqContext; 47416 22241 }47417 -1 },47418 -1 status: {47419 -1 type: 'widget',47420 -1 attributes: {47421 -1 allowed: [ 'aria-expanded', 'aria-errormessage' ]47422 -1 },47423 -1 owned: null,47424 -1 nameFrom: [ 'author' ],47425 -1 context: null,47426 -1 implicit: [ 'output' ],47427 -1 unsupported: false,47428 -1 allowedElements: [ 'section' ]47429 -1 },47430 -1 structure: {47431 -1 type: 'abstract',47432 -1 unsupported: false47433 -1 },47434 -1 switch: {47435 -1 type: 'widget',47436 -1 attributes: {47437 -1 allowed: [ 'aria-errormessage' ],47438 -1 required: [ 'aria-checked' ]47439 -1 },47440 -1 owned: null,47441 -1 nameFrom: [ 'author', 'contents' ],47442 -1 context: null,47443 -1 unsupported: false,47444 -1 allowedElements: [ 'button', {47445 -1 nodeName: 'input',47446 -1 properties: {47447 -1 type: [ 'checkbox', 'image', 'button' ]-1 22242 vNode = vNode.parent; -1 22243 } -1 22244 return reqContext; -1 22245 } -1 22246 function getAriaOwners(element) { -1 22247 var owners = [], o = null; -1 22248 while (element) { -1 22249 if (element.getAttribute('id')) { -1 22250 var id = escape_selector_default(element.getAttribute('id')); -1 22251 var doc = get_root_node_default2(element); -1 22252 o = doc.querySelector('[aria-owns~='.concat(id, ']')); -1 22253 if (o) { -1 22254 owners.push(o); 47448 22255 }47449 -1 }, {47450 -1 nodeName: 'a',47451 -1 attributes: {47452 -1 href: isNotNull-1 22256 } -1 22257 element = element.parentElement; -1 22258 } -1 22259 return owners.length ? owners : null; -1 22260 } -1 22261 function ariaRequiredParentEvaluate(node, options, virtualNode) { -1 22262 var ownGroupRoles = options && Array.isArray(options.ownGroupRoles) ? options.ownGroupRoles : []; -1 22263 var missingParents = getMissingContext(virtualNode, ownGroupRoles); -1 22264 if (!missingParents) { -1 22265 return true; -1 22266 } -1 22267 var owners = getAriaOwners(node); -1 22268 if (owners) { -1 22269 for (var _i19 = 0, l = owners.length; _i19 < l; _i19++) { -1 22270 missingParents = getMissingContext(get_node_from_tree_default(owners[_i19]), ownGroupRoles, missingParents, true); -1 22271 if (!missingParents) { -1 22272 return true; 47453 22273 }47454 -1 } ]47455 -1 },47456 -1 tab: {47457 -1 type: 'widget',47458 -1 attributes: {47459 -1 allowed: [ 'aria-selected', 'aria-expanded', 'aria-setsize', 'aria-posinset', 'aria-errormessage' ]-1 22274 } -1 22275 } -1 22276 this.data(missingParents); -1 22277 return false; -1 22278 } -1 22279 var aria_required_parent_evaluate_default = ariaRequiredParentEvaluate; -1 22280 function ariaRoledescriptionEvaluate(node) { -1 22281 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; -1 22282 var role = get_role_default(node); -1 22283 var supportedRoles = options.supportedRoles || []; -1 22284 if (supportedRoles.includes(role)) { -1 22285 return true; -1 22286 } -1 22287 if (role && role !== 'presentation' && role !== 'none') { -1 22288 return void 0; -1 22289 } -1 22290 return false; -1 22291 } -1 22292 var aria_roledescription_evaluate_default = ariaRoledescriptionEvaluate; -1 22293 function ariaUnsupportedAttrEvaluate(node, options, virtualNode) { -1 22294 var unsupportedAttrs = virtualNode.attrNames.filter(function(name) { -1 22295 var attribute = standards_default.ariaAttrs[name]; -1 22296 if (!validate_attr_default(name)) { -1 22297 return false; -1 22298 } -1 22299 var unsupported4 = attribute.unsupported; -1 22300 if (_typeof(unsupported4) !== 'object') { -1 22301 return !!unsupported4; -1 22302 } -1 22303 return !matches_default3(node, unsupported4.exceptions); -1 22304 }); -1 22305 if (unsupportedAttrs.length) { -1 22306 this.data(unsupportedAttrs); -1 22307 return true; -1 22308 } -1 22309 return false; -1 22310 } -1 22311 var aria_unsupported_attr_evaluate_default = ariaUnsupportedAttrEvaluate; -1 22312 function ariaValidAttrEvaluate(node, options, virtualNode) { -1 22313 options = Array.isArray(options.value) ? options.value : []; -1 22314 var invalid = []; -1 22315 var aria49 = /^aria-/; -1 22316 virtualNode.attrNames.forEach(function(attr) { -1 22317 if (options.indexOf(attr) === -1 && aria49.test(attr) && !validate_attr_default(attr)) { -1 22318 invalid.push(attr); -1 22319 } -1 22320 }); -1 22321 if (invalid.length) { -1 22322 this.data(invalid); -1 22323 return false; -1 22324 } -1 22325 return true; -1 22326 } -1 22327 var aria_valid_attr_evaluate_default = ariaValidAttrEvaluate; -1 22328 function ariaValidAttrValueEvaluate(node, options, virtualNode) { -1 22329 options = Array.isArray(options.value) ? options.value : []; -1 22330 var needsReview = ''; -1 22331 var messageKey = ''; -1 22332 var invalid = []; -1 22333 var aria49 = /^aria-/; -1 22334 var skipAttrs = [ 'aria-errormessage' ]; -1 22335 var preChecks = { -1 22336 'aria-controls': function ariaControls() { -1 22337 return virtualNode.attr('aria-expanded') !== 'false' && virtualNode.attr('aria-selected') !== 'false'; 47460 22338 },47461 -1 owned: null,47462 -1 nameFrom: [ 'author', 'contents' ],47463 -1 context: [ 'tablist' ],47464 -1 unsupported: false,47465 -1 allowedElements: [ {47466 -1 nodeName: [ 'button', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li' ]47467 -1 }, {47468 -1 nodeName: 'input',47469 -1 properties: {47470 -1 type: 'button'47471 -1 }47472 -1 }, {47473 -1 nodeName: 'a',47474 -1 attributes: {47475 -1 href: isNotNull-1 22339 'aria-current': function ariaCurrent(validValue) { -1 22340 if (!validValue) { -1 22341 needsReview = 'aria-current="'.concat(virtualNode.attr('aria-current'), '"'); -1 22342 messageKey = 'ariaCurrent'; 47476 22343 }47477 -1 } ]47478 -1 },47479 -1 table: {47480 -1 type: 'structure',47481 -1 attributes: {47482 -1 allowed: [ 'aria-colcount', 'aria-rowcount', 'aria-errormessage' ]47483 -1 },47484 -1 owned: {47485 -1 one: [ 'rowgroup', 'row' ]47486 -1 },47487 -1 nameFrom: [ 'author', 'contents' ],47488 -1 context: null,47489 -1 implicit: [ 'table' ],47490 -1 unsupported: false47491 -1 },47492 -1 tablist: {47493 -1 type: 'composite',47494 -1 attributes: {47495 -1 allowed: [ 'aria-activedescendant', 'aria-expanded', 'aria-level', 'aria-multiselectable', 'aria-orientation', 'aria-errormessage' ]47496 -1 },47497 -1 owned: {47498 -1 all: [ 'tab' ]47499 -1 },47500 -1 nameFrom: [ 'author' ],47501 -1 context: null,47502 -1 unsupported: false,47503 -1 allowedElements: [ 'ol', 'ul' ]47504 -1 },47505 -1 tabpanel: {47506 -1 type: 'widget',47507 -1 attributes: {47508 -1 allowed: [ 'aria-expanded', 'aria-errormessage' ]47509 -1 },47510 -1 owned: null,47511 -1 nameFrom: [ 'author' ],47512 -1 context: null,47513 -1 unsupported: false,47514 -1 allowedElements: [ 'section' ]47515 -1 },47516 -1 term: {47517 -1 type: 'structure',47518 -1 attributes: {47519 -1 allowed: [ 'aria-expanded', 'aria-errormessage' ]47520 -1 },47521 -1 owned: null,47522 -1 nameFrom: [ 'author', 'contents' ],47523 -1 context: null,47524 -1 implicit: [ 'dt' ],47525 -1 unsupported: false47526 -1 },47527 -1 textbox: {47528 -1 type: 'widget',47529 -1 attributes: {47530 -1 allowed: [ 'aria-activedescendant', 'aria-autocomplete', 'aria-multiline', 'aria-readonly', 'aria-required', 'aria-placeholder', 'aria-errormessage' ]47531 -1 },47532 -1 owned: null,47533 -1 nameFrom: [ 'author' ],47534 -1 context: null,47535 -1 implicit: [ 'input[type="text"]', 'input[type="email"]', 'input[type="password"]', 'input[type="tel"]', 'input[type="url"]', 'input:not([type])', 'textarea' ],47536 -1 unsupported: false47537 -1 },47538 -1 timer: {47539 -1 type: 'widget',47540 -1 attributes: {47541 -1 allowed: [ 'aria-expanded', 'aria-errormessage' ]47542 -1 },47543 -1 owned: null,47544 -1 nameFrom: [ 'author' ],47545 -1 context: null,47546 -1 unsupported: false47547 -1 },47548 -1 toolbar: {47549 -1 type: 'structure',47550 -1 attributes: {47551 -1 allowed: [ 'aria-activedescendant', 'aria-expanded', 'aria-orientation', 'aria-errormessage' ]47552 -1 },47553 -1 owned: null,47554 -1 nameFrom: [ 'author' ],47555 -1 context: null,47556 -1 implicit: [ 'menu[type="toolbar"]' ],47557 -1 unsupported: false,47558 -1 allowedElements: [ 'ol', 'ul' ]47559 -1 },47560 -1 tooltip: {47561 -1 type: 'structure',47562 -1 attributes: {47563 -1 allowed: [ 'aria-expanded', 'aria-errormessage' ]47564 -1 },47565 -1 owned: null,47566 -1 nameFrom: [ 'author', 'contents' ],47567 -1 context: null,47568 -1 unsupported: false47569 -1 },47570 -1 tree: {47571 -1 type: 'composite',47572 -1 attributes: {47573 -1 allowed: [ 'aria-activedescendant', 'aria-multiselectable', 'aria-required', 'aria-expanded', 'aria-orientation', 'aria-errormessage' ]47574 -1 },47575 -1 owned: {47576 -1 all: [ 'treeitem' ]47577 -1 },47578 -1 nameFrom: [ 'author' ],47579 -1 context: null,47580 -1 unsupported: false,47581 -1 allowedElements: [ 'ol', 'ul' ]47582 -1 },47583 -1 treegrid: {47584 -1 type: 'composite',47585 -1 attributes: {47586 -1 allowed: [ 'aria-activedescendant', 'aria-colcount', 'aria-expanded', 'aria-level', 'aria-multiselectable', 'aria-readonly', 'aria-required', 'aria-rowcount', 'aria-orientation', 'aria-errormessage' ]-1 22344 return; 47587 22345 },47588 -1 owned: {47589 -1 one: [ 'rowgroup', 'row' ]-1 22346 'aria-owns': function ariaOwns() { -1 22347 return virtualNode.attr('aria-expanded') !== 'false'; 47590 22348 },47591 -1 nameFrom: [ 'author' ],47592 -1 context: null,47593 -1 unsupported: false47594 -1 },47595 -1 treeitem: {47596 -1 type: 'widget',47597 -1 attributes: {47598 -1 allowed: [ 'aria-checked', 'aria-selected', 'aria-expanded', 'aria-level', 'aria-posinset', 'aria-setsize', 'aria-errormessage' ]-1 22349 'aria-describedby': function ariaDescribedby(validValue) { -1 22350 if (!validValue) { -1 22351 needsReview = 'aria-describedby="'.concat(virtualNode.attr('aria-describedby'), '"'); -1 22352 messageKey = axe._tree && axe._tree[0]._hasShadowRoot ? 'noIdShadow' : 'noId'; -1 22353 } -1 22354 return; 47599 22355 },47600 -1 owned: null,47601 -1 nameFrom: [ 'author', 'contents' ],47602 -1 context: [ 'group', 'tree' ],47603 -1 unsupported: false,47604 -1 allowedElements: [ 'li', {47605 -1 nodeName: 'a',47606 -1 attributes: {47607 -1 href: isNotNull-1 22356 'aria-labelledby': function ariaLabelledby(validValue) { -1 22357 if (!validValue) { -1 22358 needsReview = 'aria-labelledby="'.concat(virtualNode.attr('aria-labelledby'), '"'); -1 22359 messageKey = axe._tree && axe._tree[0]._hasShadowRoot ? 'noIdShadow' : 'noId'; 47608 22360 }47609 -1 } ]47610 -1 },47611 -1 widget: {47612 -1 type: 'abstract',47613 -1 unsupported: false47614 -1 },47615 -1 window: {47616 -1 nameFrom: [ 'author' ],47617 -1 type: 'abstract',47618 -1 unsupported: false-1 22361 } -1 22362 }; -1 22363 virtualNode.attrNames.forEach(function(attrName) { -1 22364 if (skipAttrs.includes(attrName) || options.includes(attrName) || !aria49.test(attrName)) { -1 22365 return; -1 22366 } -1 22367 var validValue; -1 22368 var attrValue = virtualNode.attr(attrName); -1 22369 try { -1 22370 validValue = validate_attr_value_default(virtualNode, attrName); -1 22371 } catch (e) { -1 22372 needsReview = ''.concat(attrName, '="').concat(attrValue, '"'); -1 22373 messageKey = 'idrefs'; -1 22374 } -1 22375 if ((preChecks[attrName] ? preChecks[attrName](validValue) : true) && !validValue) { -1 22376 invalid.push(''.concat(attrName, '="').concat(attrValue, '"')); -1 22377 } -1 22378 }); -1 22379 if (needsReview) { -1 22380 this.data({ -1 22381 messageKey: messageKey, -1 22382 needsReview: needsReview -1 22383 }); -1 22384 return void 0; 47619 22385 }47620 -1 };47621 -1 lookupTable.implicitHtmlRole = implicit_html_roles_default;47622 -1 lookupTable.elementsAllowedNoRole = [ {47623 -1 nodeName: [ 'base', 'body', 'caption', 'col', 'colgroup', 'datalist', 'dd', 'details', 'dt', 'head', 'html', 'keygen', 'label', 'legend', 'main', 'map', 'math', 'meta', 'meter', 'noscript', 'optgroup', 'param', 'picture', 'progress', 'script', 'source', 'style', 'template', 'textarea', 'title', 'track' ]47624 -1 }, {47625 -1 nodeName: 'area',47626 -1 attributes: {47627 -1 href: isNotNull-1 22386 if (invalid.length) { -1 22387 this.data(invalid); -1 22388 return false; 47628 22389 }47629 -1 }, {47630 -1 nodeName: 'input',47631 -1 properties: {47632 -1 type: [ 'color', 'data', 'datatime', 'file', 'hidden', 'month', 'number', 'password', 'range', 'reset', 'submit', 'time', 'week' ]-1 22390 return true; -1 22391 } -1 22392 var aria_valid_attr_value_evaluate_default = ariaValidAttrValueEvaluate; -1 22393 function deprecatedroleEvaluate(node, options, virtualNode) { -1 22394 var role = get_role_default(virtualNode, { -1 22395 dpub: true, -1 22396 fallback: true -1 22397 }); -1 22398 var roleDefinition = standards_default.ariaRoles[role]; -1 22399 if (!(roleDefinition !== null && roleDefinition !== void 0 && roleDefinition.deprecated)) { -1 22400 return false; 47633 22401 }47634 -1 }, {47635 -1 nodeName: 'link',47636 -1 attributes: {47637 -1 href: isNotNull-1 22402 this.data(role); -1 22403 return true; -1 22404 } -1 22405 function nonePresentationOnElementWithNoImplicitRole(virtualNode, explicitRoles) { -1 22406 var hasImplicitRole = implicit_role_default(virtualNode); -1 22407 return !hasImplicitRole && explicitRoles.length === 2 && explicitRoles.includes('none') && explicitRoles.includes('presentation'); -1 22408 } -1 22409 function fallbackroleEvaluate(node, options, virtualNode) { -1 22410 var explicitRoles = token_list_default(virtualNode.attr('role')); -1 22411 if (explicitRoles.length <= 1) { -1 22412 return false; 47638 22413 }47639 -1 }, {47640 -1 nodeName: 'menu',47641 -1 attributes: {47642 -1 type: 'context'-1 22414 return nonePresentationOnElementWithNoImplicitRole(virtualNode, explicitRoles) ? void 0 : true; -1 22415 } -1 22416 var fallbackrole_evaluate_default = fallbackroleEvaluate; -1 22417 function hasGlobalAriaAttributeEvaluate(node, options, virtualNode) { -1 22418 var globalAttrs = get_global_aria_attrs_default().filter(function(attr) { -1 22419 return virtualNode.hasAttr(attr); -1 22420 }); -1 22421 this.data(globalAttrs); -1 22422 return globalAttrs.length > 0; -1 22423 } -1 22424 var has_global_aria_attribute_evaluate_default = hasGlobalAriaAttributeEvaluate; -1 22425 function hasWidgetRoleEvaluate(node) { -1 22426 var role = node.getAttribute('role'); -1 22427 if (role === null) { -1 22428 return false; 47643 22429 }47644 -1 }, {47645 -1 nodeName: 'menuitem',47646 -1 attributes: {47647 -1 type: [ 'command', 'checkbox', 'radio' ]-1 22430 var roleType = get_role_type_default(role); -1 22431 return roleType === 'widget' || roleType === 'composite'; -1 22432 } -1 22433 var has_widget_role_evaluate_default = hasWidgetRoleEvaluate; -1 22434 function invalidroleEvaluate(node, options, virtualNode) { -1 22435 var allRoles = token_list_default(virtualNode.attr('role')); -1 22436 var allInvalid = allRoles.every(function(role) { -1 22437 return !is_valid_role_default(role, { -1 22438 allowAbstract: true -1 22439 }); -1 22440 }); -1 22441 if (allInvalid) { -1 22442 this.data(allRoles); -1 22443 return true; -1 22444 } -1 22445 return false; -1 22446 } -1 22447 var invalidrole_evaluate_default = invalidroleEvaluate; -1 22448 function isElementFocusableEvaluate(node, options, virtualNode) { -1 22449 return is_focusable_default(virtualNode); -1 22450 } -1 22451 var is_element_focusable_evaluate_default = isElementFocusableEvaluate; -1 22452 function noImplicitExplicitLabelEvaluate(node, options, virtualNode) { -1 22453 var role = get_role_default(virtualNode, { -1 22454 noImplicit: true -1 22455 }); -1 22456 this.data(role); -1 22457 var label5; -1 22458 var accText; -1 22459 try { -1 22460 label5 = sanitize_default(label_text_default(virtualNode)).toLowerCase(); -1 22461 accText = sanitize_default(accessible_text_virtual_default(virtualNode)).toLowerCase(); -1 22462 } catch (e) { -1 22463 return void 0; -1 22464 } -1 22465 if (!accText && !label5) { -1 22466 return false; -1 22467 } -1 22468 if (!accText && label5) { -1 22469 return void 0; -1 22470 } -1 22471 if (!accText.includes(label5)) { -1 22472 return void 0; -1 22473 } -1 22474 return false; -1 22475 } -1 22476 var no_implicit_explicit_label_evaluate_default = noImplicitExplicitLabelEvaluate; -1 22477 function unsupportedroleEvaluate(node, options, virtualNode) { -1 22478 return is_unsupported_role_default(get_role_default(virtualNode)); -1 22479 } -1 22480 var unsupportedrole_evaluate_default = unsupportedroleEvaluate; -1 22481 var VALID_TAG_NAMES_FOR_SCROLLABLE_REGIONS = { -1 22482 ARTICLE: true, -1 22483 ASIDE: true, -1 22484 NAV: true, -1 22485 SECTION: true -1 22486 }; -1 22487 var VALID_ROLES_FOR_SCROLLABLE_REGIONS = { -1 22488 application: true, -1 22489 banner: false, -1 22490 complementary: true, -1 22491 contentinfo: true, -1 22492 form: true, -1 22493 main: true, -1 22494 navigation: true, -1 22495 region: true, -1 22496 search: false -1 22497 }; -1 22498 function validScrollableTagName(node) { -1 22499 var nodeName2 = node.nodeName.toUpperCase(); -1 22500 return VALID_TAG_NAMES_FOR_SCROLLABLE_REGIONS[nodeName2] || false; -1 22501 } -1 22502 function validScrollableRole(node, options) { -1 22503 var role = get_explicit_role_default(node); -1 22504 if (!role) { -1 22505 return false; 47648 22506 }47649 -1 }, {47650 -1 nodeName: 'select',47651 -1 condition: function condition(vNode) {47652 -1 if (!(vNode instanceof axe.AbstractVirtualNode)) {47653 -1 vNode = axe.utils.getNodeFromTree(vNode);47654 -1 }47655 -1 return Number(vNode.attr('size')) > 1;-1 22507 return VALID_ROLES_FOR_SCROLLABLE_REGIONS[role] || options.roles.includes(role) || false; -1 22508 } -1 22509 function validScrollableSemanticsEvaluate(node, options) { -1 22510 return validScrollableRole(node, options) || validScrollableTagName(node); -1 22511 } -1 22512 var valid_scrollable_semantics_evaluate_default = validScrollableSemanticsEvaluate; -1 22513 var color_exports = {}; -1 22514 __export(color_exports, { -1 22515 Color: function Color() { -1 22516 return color_default; 47656 22517 },47657 -1 properties: {47658 -1 multiple: true47659 -1 }47660 -1 }, {47661 -1 nodeName: [ 'clippath', 'cursor', 'defs', 'desc', 'feblend', 'fecolormatrix', 'fecomponenttransfer', 'fecomposite', 'feconvolvematrix', 'fediffuselighting', 'fedisplacementmap', 'fedistantlight', 'fedropshadow', 'feflood', 'fefunca', 'fefuncb', 'fefuncg', 'fefuncr', 'fegaussianblur', 'feimage', 'femerge', 'femergenode', 'femorphology', 'feoffset', 'fepointlight', 'fespecularlighting', 'fespotlight', 'fetile', 'feturbulence', 'filter', 'hatch', 'hatchpath', 'lineargradient', 'marker', 'mask', 'meshgradient', 'meshpatch', 'meshrow', 'metadata', 'mpath', 'pattern', 'radialgradient', 'solidcolor', 'stop', 'switch', 'view' ]47662 -1 } ];47663 -1 lookupTable.elementsAllowedAnyRole = [ {47664 -1 nodeName: 'a',47665 -1 attributes: {47666 -1 href: isNull47667 -1 }47668 -1 }, {47669 -1 nodeName: 'img',47670 -1 attributes: {47671 -1 alt: isNull47672 -1 }47673 -1 }, {47674 -1 nodeName: [ 'abbr', 'address', 'canvas', 'div', 'p', 'pre', 'blockquote', 'ins', 'del', 'output', 'span', 'table', 'tbody', 'thead', 'tfoot', 'td', 'em', 'strong', 'small', 's', 'cite', 'q', 'dfn', 'abbr', 'time', 'code', 'var', 'samp', 'kbd', 'sub', 'sup', 'i', 'b', 'u', 'mark', 'ruby', 'rt', 'rp', 'bdi', 'bdo', 'br', 'wbr', 'th', 'tr' ]47675 -1 } ];47676 -1 lookupTable.evaluateRoleForElement = {47677 -1 A: function A(_ref35) {47678 -1 var node = _ref35.node, out = _ref35.out;47679 -1 if (node.namespaceURI === 'http://www.w3.org/2000/svg') {47680 -1 return true;47681 -1 }47682 -1 if (node.href.length) {47683 -1 return out;47684 -1 }47685 -1 return true;-1 22518 centerPointOfRect: function centerPointOfRect() { -1 22519 return center_point_of_rect_default; 47686 22520 },47687 -1 AREA: function AREA(_ref36) {47688 -1 var node = _ref36.node;47689 -1 return !node.href;-1 22521 elementHasImage: function elementHasImage() { -1 22522 return element_has_image_default; 47690 22523 },47691 -1 BUTTON: function BUTTON(_ref37) {47692 -1 var node = _ref37.node, role = _ref37.role, out = _ref37.out;47693 -1 if (node.getAttribute('type') === 'menu') {47694 -1 return role === 'menuitem';47695 -1 }47696 -1 return out;-1 22524 elementIsDistinct: function elementIsDistinct() { -1 22525 return element_is_distinct_default; 47697 22526 },47698 -1 IMG: function IMG(_ref38) {47699 -1 var node = _ref38.node, role = _ref38.role, out = _ref38.out;47700 -1 switch (node.alt) {47701 -1 case null:47702 -1 return out;47703 -147704 -1 case '':47705 -1 return role === 'presentation' || role === 'none';47706 -147707 -1 default:47708 -1 return role !== 'presentation' && role !== 'none';47709 -1 }-1 22527 filteredRectStack: function filteredRectStack() { -1 22528 return filtered_rect_stack_default; 47710 22529 },47711 -1 INPUT: function INPUT(_ref39) {47712 -1 var node = _ref39.node, role = _ref39.role, out = _ref39.out;47713 -1 switch (node.type) {47714 -1 case 'button':47715 -1 case 'image':47716 -1 return out;47717 -147718 -1 case 'checkbox':47719 -1 if (role === 'button' && node.hasAttribute('aria-pressed')) {47720 -1 return true;47721 -1 }47722 -1 return out;47723 -147724 -1 case 'radio':47725 -1 return role === 'menuitemradio';47726 -147727 -1 case 'text':47728 -1 return role === 'combobox' || role === 'searchbox' || role === 'spinbutton';47729 -147730 -1 case 'tel':47731 -1 return role === 'combobox' || role === 'spinbutton';47732 -147733 -1 case 'url':47734 -1 case 'search':47735 -1 case 'email':47736 -1 return role === 'combobox';47737 -147738 -1 default:47739 -1 return false;47740 -1 }-1 22530 flattenColors: function flattenColors() { -1 22531 return flatten_colors_default; 47741 22532 },47742 -1 LI: function LI(_ref40) {47743 -1 var node = _ref40.node, out = _ref40.out;47744 -1 var hasImplicitListitemRole = axe.utils.matchesSelector(node, 'ol li, ul li');47745 -1 if (hasImplicitListitemRole) {47746 -1 return out;47747 -1 }47748 -1 return true;-1 22533 flattenShadowColors: function flattenShadowColors() { -1 22534 return flatten_shadow_colors_default; 47749 22535 },47750 -1 MENU: function MENU(_ref41) {47751 -1 var node = _ref41.node;47752 -1 if (node.getAttribute('type') === 'context') {47753 -1 return false;47754 -1 }47755 -1 return true;-1 22536 getBackgroundColor: function getBackgroundColor() { -1 22537 return _getBackgroundColor; 47756 22538 },47757 -1 OPTION: function OPTION(_ref42) {47758 -1 var node = _ref42.node;47759 -1 var withinOptionList = axe.utils.matchesSelector(node, 'select > option, datalist > option, optgroup > option');47760 -1 return !withinOptionList;-1 22539 getBackgroundStack: function getBackgroundStack() { -1 22540 return get_background_stack_default; 47761 22541 },47762 -1 SELECT: function SELECT(_ref43) {47763 -1 var node = _ref43.node, role = _ref43.role;47764 -1 return !node.multiple && node.size <= 1 && role === 'menu';-1 22542 getContrast: function getContrast() { -1 22543 return get_contrast_default; 47765 22544 },47766 -1 SVG: function SVG(_ref44) {47767 -1 var node = _ref44.node, out = _ref44.out;47768 -1 if (node.parentNode && node.parentNode.namespaceURI === 'http://www.w3.org/2000/svg') {47769 -1 return true;47770 -1 }47771 -1 return out;-1 22545 getForegroundColor: function getForegroundColor() { -1 22546 return get_foreground_color_default; -1 22547 }, -1 22548 getOwnBackgroundColor: function getOwnBackgroundColor() { -1 22549 return get_own_background_color_default; -1 22550 }, -1 22551 getRectStack: function getRectStack() { -1 22552 return get_rect_stack_default; -1 22553 }, -1 22554 getTextShadowColors: function getTextShadowColors() { -1 22555 return get_text_shadow_colors_default; -1 22556 }, -1 22557 hasValidContrastRatio: function hasValidContrastRatio() { -1 22558 return has_valid_contrast_ratio_default; -1 22559 }, -1 22560 incompleteData: function incompleteData() { -1 22561 return incomplete_data_default; 47772 22562 }47773 -1 };47774 -1 lookupTable.rolesOfType = {47775 -1 widget: [ 'button', 'checkbox', 'dialog', 'gridcell', 'link', 'log', 'marquee', 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'option', 'progressbar', 'radio', 'scrollbar', 'searchbox', 'slider', 'spinbutton', 'status', 'switch', 'tab', 'tabpanel', 'textbox', 'timer', 'tooltip', 'tree', 'treeitem' ]47776 -1 };47777 -1 var lookup_table_default = lookupTable;47778 -1 function implicitNodes(role) {47779 -1 var implicit = null;47780 -1 var roles = lookup_table_default.role[role];47781 -1 if (roles && roles.implicit) {47782 -1 implicit = clone_default(roles.implicit);-1 22563 }); -1 22564 function centerPointOfRect(rect) { -1 22565 if (rect.left > window.innerWidth) { -1 22566 return void 0; 47783 22567 }47784 -1 return implicit;47785 -1 }47786 -1 var implicit_nodes_default = implicitNodes;47787 -1 function isAccessibleRef(node) {47788 -1 return !!get_accessible_refs_default(node).length;47789 -1 }47790 -1 var is_accessible_ref_default = isAccessibleRef;47791 -1 function label3(node) {47792 -1 node = get_node_from_tree_default(node);47793 -1 return label_virtual_default(node);47794 -1 }47795 -1 var label_default2 = label3;47796 -1 function requiredAttr(role) {47797 -1 var roleDef = standards_default.ariaRoles[role];47798 -1 if (!roleDef || !Array.isArray(roleDef.requiredAttrs)) {47799 -1 return [];-1 22568 if (rect.top > window.innerHeight) { -1 22569 return void 0; 47800 22570 }47801 -1 return _toConsumableArray(roleDef.requiredAttrs);-1 22571 var x = Math.min(Math.ceil(rect.left + rect.width / 2), window.innerWidth - 1); -1 22572 var y = Math.min(Math.ceil(rect.top + rect.height / 2), window.innerHeight - 1); -1 22573 return { -1 22574 x: x, -1 22575 y: y -1 22576 }; 47802 22577 }47803 -1 var required_attr_default = requiredAttr;47804 -1 function requiredContext(role) {47805 -1 var roleDef = standards_default.ariaRoles[role];47806 -1 if (!roleDef || !Array.isArray(roleDef.requiredContext)) {47807 -1 return null;47808 -1 }47809 -1 return _toConsumableArray(roleDef.requiredContext);-1 22578 var center_point_of_rect_default = centerPointOfRect; -1 22579 function _getFonts(style) { -1 22580 return style.getPropertyValue('font-family').split(/[,;]/g).map(function(font) { -1 22581 return font.trim().toLowerCase(); -1 22582 }); 47810 22583 }47811 -1 var required_context_default = requiredContext;47812 -1 function requiredOwned(role) {47813 -1 var roleDef = standards_default.ariaRoles[role];47814 -1 if (!roleDef || !Array.isArray(roleDef.requiredOwned)) {47815 -1 return null;-1 22584 function elementIsDistinct(node, ancestorNode) { -1 22585 var nodeStyle = window.getComputedStyle(node); -1 22586 if (nodeStyle.getPropertyValue('background-image') !== 'none') { -1 22587 return true; 47816 22588 }47817 -1 return _toConsumableArray(roleDef.requiredOwned);47818 -1 }47819 -1 var required_owned_default = requiredOwned;47820 -1 function validateAttrValue(node, attr) {47821 -1 var matches14;47822 -1 var list;47823 -1 var value = node.getAttribute(attr);47824 -1 var attrInfo = standards_default.ariaAttrs[attr];47825 -1 var doc = get_root_node_default2(node);47826 -1 if (!attrInfo) {-1 22589 var hasBorder = [ 'border-bottom', 'border-top', 'outline' ].reduce(function(result, edge) { -1 22590 var borderClr = new color_default(); -1 22591 borderClr.parseString(nodeStyle.getPropertyValue(edge + '-color')); -1 22592 return result || nodeStyle.getPropertyValue(edge + '-style') !== 'none' && parseFloat(nodeStyle.getPropertyValue(edge + '-width')) > 0 && borderClr.alpha !== 0; -1 22593 }, false); -1 22594 if (hasBorder) { 47827 22595 return true; 47828 22596 }47829 -1 if (attrInfo.allowEmpty && (!value || value.trim() === '')) {-1 22597 var parentStyle = window.getComputedStyle(ancestorNode); -1 22598 if (_getFonts(nodeStyle)[0] !== _getFonts(parentStyle)[0]) { 47830 22599 return true; 47831 22600 }47832 -1 switch (attrInfo.type) {47833 -1 case 'boolean':47834 -1 return [ 'true', 'false' ].includes(value.toLowerCase());47835 -147836 -1 case 'nmtoken':47837 -1 return typeof value === 'string' && attrInfo.values.includes(value.toLowerCase());47838 -147839 -1 case 'nmtokens':47840 -1 list = token_list_default(value);47841 -1 return list.reduce(function(result, token) {47842 -1 return result && attrInfo.values.includes(token);47843 -1 }, list.length !== 0);47844 -147845 -1 case 'idref':47846 -1 return !!(value && doc.getElementById(value));47847 -147848 -1 case 'idrefs':47849 -1 list = token_list_default(value);47850 -1 return list.some(function(token) {47851 -1 return doc.getElementById(token);47852 -1 });47853 -147854 -1 case 'string':47855 -1 return value.trim() !== '';47856 -147857 -1 case 'decimal':47858 -1 matches14 = value.match(/^[-+]?([0-9]*)\.?([0-9]*)$/);47859 -1 return !!(matches14 && (matches14[1] || matches14[2]));47860 -147861 -1 case 'int':47862 -1 var minValue = typeof attrInfo.minValue !== 'undefined' ? attrInfo.minValue : -Infinity;47863 -1 return /^[-+]?[0-9]+$/.test(value) && parseInt(value) >= minValue;-1 22601 var hasStyle = [ 'text-decoration-line', 'text-decoration-style', 'font-weight', 'font-style', 'font-size' ].reduce(function(result, cssProp) { -1 22602 return result || nodeStyle.getPropertyValue(cssProp) !== parentStyle.getPropertyValue(cssProp); -1 22603 }, false); -1 22604 var tDec = nodeStyle.getPropertyValue('text-decoration'); -1 22605 if (tDec.split(' ').length < 3) { -1 22606 hasStyle = hasStyle || tDec !== parentStyle.getPropertyValue('text-decoration'); 47864 22607 } -1 22608 return hasStyle; 47865 22609 }47866 -1 var validate_attr_value_default = validateAttrValue;47867 -1 function validateAttr(att) {47868 -1 var attrDefinition = standards_default.ariaAttrs[att];47869 -1 return !!attrDefinition;47870 -1 }47871 -1 var validate_attr_default = validateAttr;47872 -1 function abstractroleEvaluate(node, options, virtualNode) {47873 -1 var abstractRoles = token_list_default(virtualNode.attr('role')).filter(function(role) {47874 -1 return get_role_type_default(role) === 'abstract';47875 -1 });47876 -1 if (abstractRoles.length > 0) {47877 -1 this.data(abstractRoles);47878 -1 return true;-1 22610 var element_is_distinct_default = elementIsDistinct; -1 22611 function getRectStack2(elm) { -1 22612 var boundingStack = get_element_stack_default(elm); -1 22613 var filteredArr = get_text_element_stack_default(elm); -1 22614 if (!filteredArr || filteredArr.length <= 1) { -1 22615 return [ boundingStack ]; 47879 22616 }47880 -1 return false;-1 22617 if (filteredArr.some(function(stack) { -1 22618 return stack === void 0; -1 22619 })) { -1 22620 return null; -1 22621 } -1 22622 filteredArr.splice(0, 0, boundingStack); -1 22623 return filteredArr; 47881 22624 }47882 -1 var abstractrole_evaluate_default = abstractroleEvaluate;47883 -1 function ariaAllowedAttrEvaluate(node, options, virtualNode) {47884 -1 var invalid = [];47885 -1 var role = get_role_default(virtualNode);47886 -1 var attrs = virtualNode.attrNames;47887 -1 var allowed = allowed_attr_default(role);47888 -1 if (Array.isArray(options[role])) {47889 -1 allowed = unique_array_default(options[role].concat(allowed));-1 22625 var get_rect_stack_default = getRectStack2; -1 22626 function filteredRectStack(elm) { -1 22627 var rectStack = get_rect_stack_default(elm); -1 22628 if (rectStack && rectStack.length === 1) { -1 22629 return rectStack[0]; 47890 22630 }47891 -1 if (role && allowed) {47892 -1 for (var _i14 = 0; _i14 < attrs.length; _i14++) {47893 -1 var attrName = attrs[_i14];47894 -1 if (validate_attr_default(attrName) && !allowed.includes(attrName)) {47895 -1 invalid.push(attrName + '="' + virtualNode.attr(attrName) + '"');-1 22631 if (rectStack && rectStack.length > 1) { -1 22632 var boundingStack = rectStack.shift(); -1 22633 var isSame; -1 22634 rectStack.forEach(function(rectList, index) { -1 22635 if (index === 0) { -1 22636 return; 47896 22637 } -1 22638 var rectA = rectStack[index - 1], rectB = rectStack[index]; -1 22639 isSame = rectA.every(function(element, elementIndex) { -1 22640 return element === rectB[elementIndex]; -1 22641 }) || boundingStack.includes(elm); -1 22642 }); -1 22643 if (!isSame) { -1 22644 incomplete_data_default.set('bgColor', 'elmPartiallyObscuring'); -1 22645 return null; 47897 22646 } -1 22647 return rectStack[0]; 47898 22648 }47899 -1 if (invalid.length) {47900 -1 this.data(invalid);47901 -1 return false;-1 22649 incomplete_data_default.set('bgColor', 'outsideViewport'); -1 22650 return null; -1 22651 } -1 22652 var filtered_rect_stack_default = filteredRectStack; -1 22653 function clamp(value, min, max) { -1 22654 return Math.min(Math.max(min, value), max); -1 22655 } -1 22656 var blendFunctions = { -1 22657 normal: function normal(Cb, Cs) { -1 22658 return Cs; -1 22659 }, -1 22660 multiply: function multiply(Cb, Cs) { -1 22661 return Cs * Cb; -1 22662 }, -1 22663 screen: function screen(Cb, Cs) { -1 22664 return Cb + Cs - Cb * Cs; -1 22665 }, -1 22666 overlay: function overlay(Cb, Cs) { -1 22667 return this['hard-light'](Cs, Cb); -1 22668 }, -1 22669 darken: function darken(Cb, Cs) { -1 22670 return Math.min(Cb, Cs); -1 22671 }, -1 22672 lighten: function lighten(Cb, Cs) { -1 22673 return Math.max(Cb, Cs); -1 22674 }, -1 22675 'color-dodge': function colorDodge(Cb, Cs) { -1 22676 return Cb === 0 ? 0 : Cs === 1 ? 1 : Math.min(1, Cb / (1 - Cs)); -1 22677 }, -1 22678 'color-burn': function colorBurn(Cb, Cs) { -1 22679 return Cb === 1 ? 1 : Cs === 0 ? 0 : 1 - Math.min(1, (1 - Cb) / Cs); -1 22680 }, -1 22681 'hard-light': function hardLight(Cb, Cs) { -1 22682 return Cs <= .5 ? this.multiply(Cb, 2 * Cs) : this.screen(Cb, 2 * Cs - 1); -1 22683 }, -1 22684 'soft-light': function softLight(Cb, Cs) { -1 22685 if (Cs <= .5) { -1 22686 return Cb - (1 - 2 * Cs) * Cb * (1 - Cb); -1 22687 } else { -1 22688 var D = Cb <= .25 ? ((16 * Cb - 12) * Cb + 4) * Cb : Math.sqrt(Cb); -1 22689 return Cb + (2 * Cs - 1) * (D - Cb); -1 22690 } -1 22691 }, -1 22692 difference: function difference(Cb, Cs) { -1 22693 return Math.abs(Cb - Cs); -1 22694 }, -1 22695 exclusion: function exclusion(Cb, Cs) { -1 22696 return Cb + Cs - 2 * Cb * Cs; 47902 22697 }47903 -1 return true;-1 22698 }; -1 22699 function simpleAlphaCompositing(Cs, \u03b1s, Cb, \u03b1b, blendMode) { -1 22700 return \u03b1s * (1 - \u03b1b) * Cs + \u03b1s * \u03b1b * blendFunctions[blendMode](Cb / 255, Cs / 255) * 255 + (1 - \u03b1s) * \u03b1b * Cb; 47904 22701 }47905 -1 var aria_allowed_attr_evaluate_default = ariaAllowedAttrEvaluate;47906 -1 function ariaAllowedRoledEvaluate(node) {47907 -1 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};47908 -1 var _options$allowImplici = options.allowImplicit, allowImplicit = _options$allowImplici === void 0 ? true : _options$allowImplici, _options$ignoredTags = options.ignoredTags, ignoredTags = _options$ignoredTags === void 0 ? [] : _options$ignoredTags;47909 -1 var tagName = node.nodeName.toUpperCase();47910 -1 if (ignoredTags.map(function(t) {47911 -1 return t.toUpperCase();47912 -1 }).includes(tagName)) {47913 -1 return true;-1 22702 function flattenColors(fgColor, bgColor) { -1 22703 var blendMode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'normal'; -1 22704 var r = simpleAlphaCompositing(fgColor.red, fgColor.alpha, bgColor.red, bgColor.alpha, blendMode); -1 22705 var g = simpleAlphaCompositing(fgColor.green, fgColor.alpha, bgColor.green, bgColor.alpha, blendMode); -1 22706 var b = simpleAlphaCompositing(fgColor.blue, fgColor.alpha, bgColor.blue, bgColor.alpha, blendMode); -1 22707 var \u03b1o = clamp(fgColor.alpha + bgColor.alpha * (1 - fgColor.alpha), 0, 1); -1 22708 var Cr = Math.round(r / \u03b1o); -1 22709 var Cg = Math.round(g / \u03b1o); -1 22710 var Cb = Math.round(b / \u03b1o); -1 22711 return new color_default(Cr, Cg, Cb, \u03b1o); -1 22712 } -1 22713 var flatten_colors_default = flattenColors; -1 22714 function flattenColors2(fgColor, bgColor) { -1 22715 var alpha = fgColor.alpha; -1 22716 var r = (1 - alpha) * bgColor.red + alpha * fgColor.red; -1 22717 var g = (1 - alpha) * bgColor.green + alpha * fgColor.green; -1 22718 var b = (1 - alpha) * bgColor.blue + alpha * fgColor.blue; -1 22719 var a = fgColor.alpha + bgColor.alpha * (1 - fgColor.alpha); -1 22720 return new color_default(r, g, b, a); -1 22721 } -1 22722 var flatten_shadow_colors_default = flattenColors2; -1 22723 function isInlineDescendant(node, descendant) { -1 22724 var CONTAINED_BY = Node.DOCUMENT_POSITION_CONTAINED_BY; -1 22725 if (!(node.compareDocumentPosition(descendant) & CONTAINED_BY)) { -1 22726 return false; 47914 22727 }47915 -1 var unallowedRoles = get_element_unallowed_roles_default(node, allowImplicit);47916 -1 if (unallowedRoles.length) {47917 -1 this.data(unallowedRoles);47918 -1 if (!is_visible_default(node, true)) {47919 -1 return void 0;47920 -1 }-1 22728 var style = window.getComputedStyle(descendant); -1 22729 var display = style.getPropertyValue('display'); -1 22730 if (!display.includes('inline')) { 47921 22731 return false; 47922 22732 }47923 -1 return true;-1 22733 var position = style.getPropertyValue('position'); -1 22734 return position === 'static'; 47924 22735 }47925 -1 var aria_allowed_role_evaluate_default = ariaAllowedRoledEvaluate;47926 -1 function ariaErrormessageEvaluate(node, options) {47927 -1 options = Array.isArray(options) ? options : [];47928 -1 var attr = node.getAttribute('aria-errormessage');47929 -1 var hasAttr = node.hasAttribute('aria-errormessage');47930 -1 var invaid = node.getAttribute('aria-invalid');47931 -1 var hasInvallid = node.hasAttribute('aria-invalid');47932 -1 if (!hasInvallid || invaid === 'false') {47933 -1 return true;47934 -1 }47935 -1 var doc = get_root_node_default2(node);47936 -1 function validateAttrValue2(attr2) {47937 -1 if (attr2.trim() === '') {47938 -1 return standards_default.ariaAttrs['aria-errormessage'].allowEmpty;47939 -1 }47940 -1 var idref = attr2 && doc.getElementById(attr2);47941 -1 if (idref) {47942 -1 return idref.getAttribute('role') === 'alert' || idref.getAttribute('aria-live') === 'assertive' || idref.getAttribute('aria-live') === 'polite' || token_list_default(node.getAttribute('aria-describedby')).indexOf(attr2) > -1;-1 22736 function calculateObscuringElement(elmIndex, elmStack, originalElm) { -1 22737 for (var _i20 = elmIndex - 1; _i20 >= 0; _i20--) { -1 22738 if (!isInlineDescendant(originalElm, elmStack[_i20])) { -1 22739 return true; 47943 22740 }47944 -1 return;47945 -1 }47946 -1 if (options.indexOf(attr) === -1 && hasAttr) {47947 -1 this.data(token_list_default(attr));47948 -1 return validateAttrValue2(attr);-1 22741 elmStack.splice(_i20, 1); 47949 22742 }47950 -1 return true;47951 -1 }47952 -1 var aria_errormessage_evaluate_default = ariaErrormessageEvaluate;47953 -1 function ariaHiddenBodyEvaluate(node, options, virtualNode) {47954 -1 return virtualNode.attr('aria-hidden') !== 'true';-1 22743 return false; 47955 22744 }47956 -1 var aria_hidden_body_evaluate_default = ariaHiddenBodyEvaluate;47957 -1 function ariaProhibitedAttrEvaluate(node) {47958 -1 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};47959 -1 var virtualNode = arguments.length > 2 ? arguments[2] : undefined;47960 -1 var extraElementsAllowedAriaLabel = options.elementsAllowedAriaLabel || [];47961 -1 var prohibitedList = listProhibitedAttrs(virtualNode, extraElementsAllowedAriaLabel);47962 -1 var prohibited = prohibitedList.filter(function(attrName) {47963 -1 if (!virtualNode.attrNames.includes(attrName)) {47964 -1 return false;-1 22745 function sortPageBackground(elmStack) { -1 22746 var bodyIndex = elmStack.indexOf(document.body); -1 22747 var bgNodes = elmStack; -1 22748 var htmlBgColor = get_own_background_color_default(window.getComputedStyle(document.documentElement)); -1 22749 if (bodyIndex > 1 && htmlBgColor.alpha === 0 && !element_has_image_default(document.documentElement)) { -1 22750 if (bodyIndex > 1) { -1 22751 bgNodes.splice(bodyIndex, 1); -1 22752 bgNodes.push(document.body); -1 22753 } -1 22754 var htmlIndex = bgNodes.indexOf(document.documentElement); -1 22755 if (htmlIndex > 0) { -1 22756 bgNodes.splice(htmlIndex, 1); -1 22757 bgNodes.push(document.documentElement); 47965 22758 }47966 -1 return sanitize_default(virtualNode.attr(attrName)) !== '';47967 -1 });47968 -1 if (prohibited.length === 0) {47969 -1 return false;47970 22759 }47971 -1 this.data(prohibited);47972 -1 var hasTextContent = sanitize_default(subtree_text_default(virtualNode)) !== '';47973 -1 return hasTextContent ? void 0 : true;-1 22760 return bgNodes; 47974 22761 }47975 -1 function listProhibitedAttrs(virtualNode, elementsAllowedAriaLabel) {47976 -1 var role = get_role_default(virtualNode, {47977 -1 chromium: true47978 -1 });47979 -1 var roleSpec = standards_default.ariaRoles[role];47980 -1 if (roleSpec) {47981 -1 return roleSpec.prohibitedAttrs || [];-1 22762 function getBackgroundStack(elm) { -1 22763 var elmStack = filtered_rect_stack_default(elm); -1 22764 if (elmStack === null) { -1 22765 return null; 47982 22766 }47983 -1 var nodeName2 = virtualNode.props.nodeName;47984 -1 if (!!role || elementsAllowedAriaLabel.includes(nodeName2)) {47985 -1 return [];-1 22767 elmStack = reduce_to_elements_below_floating_default(elmStack, elm); -1 22768 elmStack = sortPageBackground(elmStack); -1 22769 var elmIndex = elmStack.indexOf(elm); -1 22770 if (calculateObscuringElement(elmIndex, elmStack, elm)) { -1 22771 incomplete_data_default.set('bgColor', 'bgOverlap'); -1 22772 return null; 47986 22773 }47987 -1 return [ 'aria-label', 'aria-labelledby' ];-1 22774 return elmIndex !== -1 ? elmStack : null; 47988 22775 }47989 -1 var aria_prohibited_attr_evaluate_default = ariaProhibitedAttrEvaluate;47990 -1 var standards_exports = {};47991 -1 __export(standards_exports, {47992 -1 getAriaRolesByType: function getAriaRolesByType() {47993 -1 return get_aria_roles_by_type_default;47994 -1 },47995 -1 getAriaRolesSupportingNameFromContent: function getAriaRolesSupportingNameFromContent() {47996 -1 return get_aria_roles_supporting_name_from_content_default;47997 -1 },47998 -1 getElementSpec: function getElementSpec() {47999 -1 return get_element_spec_default;48000 -1 },48001 -1 getElementsByContentType: function getElementsByContentType() {48002 -1 return get_elements_by_content_type_default;48003 -1 },48004 -1 getGlobalAriaAttrs: function getGlobalAriaAttrs() {48005 -1 return get_global_aria_attrs_default;48006 -1 },48007 -1 implicitHtmlRoles: function implicitHtmlRoles() {48008 -1 return implicit_html_roles_default;-1 22776 var get_background_stack_default = getBackgroundStack; -1 22777 function getTextShadowColors(node) { -1 22778 var _ref55 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, minRatio = _ref55.minRatio, maxRatio = _ref55.maxRatio; -1 22779 var style = window.getComputedStyle(node); -1 22780 var textShadow = style.getPropertyValue('text-shadow'); -1 22781 if (textShadow === 'none') { -1 22782 return []; 48009 22783 }48010 -1 });48011 -1 function ariaRequiredAttrEvaluate(node) {48012 -1 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};48013 -1 var virtualNode = arguments.length > 2 ? arguments[2] : undefined;48014 -1 var missing = [];48015 -1 var attrs = virtualNode.attrNames;48016 -1 if (attrs.length) {48017 -1 var role = get_explicit_role_default(virtualNode);48018 -1 var required = required_attr_default(role);48019 -1 var elmSpec = get_element_spec_default(virtualNode);48020 -1 if (Array.isArray(options[role])) {48021 -1 required = unique_array_default(options[role], required);48022 -1 }48023 -1 if (role && required) {48024 -1 for (var _i15 = 0, l = required.length; _i15 < l; _i15++) {48025 -1 var attr = required[_i15];48026 -1 if (!virtualNode.attr(attr) && !(elmSpec.implicitAttrs && typeof elmSpec.implicitAttrs[attr] !== 'undefined')) {48027 -1 missing.push(attr);48028 -1 }48029 -1 }-1 22784 var fontSizeStr = style.getPropertyValue('font-size'); -1 22785 var fontSize = parseInt(fontSizeStr); -1 22786 assert_default(isNaN(fontSize) === false, 'Unable to determine font-size value '.concat(fontSizeStr)); -1 22787 var shadowColors = []; -1 22788 var shadows = parseTextShadows(textShadow); -1 22789 shadows.forEach(function(_ref56) { -1 22790 var colorStr = _ref56.colorStr, pixels = _ref56.pixels; -1 22791 colorStr = colorStr || style.getPropertyValue('color'); -1 22792 var _pixels = _slicedToArray(pixels, 3), offsetY = _pixels[0], offsetX = _pixels[1], _pixels$ = _pixels[2], blurRadius = _pixels$ === void 0 ? 0 : _pixels$; -1 22793 if ((!minRatio || blurRadius >= fontSize * minRatio) && (!maxRatio || blurRadius < fontSize * maxRatio)) { -1 22794 var color11 = textShadowColor({ -1 22795 colorStr: colorStr, -1 22796 offsetY: offsetY, -1 22797 offsetX: offsetX, -1 22798 blurRadius: blurRadius, -1 22799 fontSize: fontSize -1 22800 }); -1 22801 shadowColors.push(color11); 48030 22802 }48031 -1 }48032 -1 if (missing.length) {48033 -1 this.data(missing);48034 -1 return false;48035 -1 }48036 -1 return true;-1 22803 }); -1 22804 return shadowColors; 48037 22805 }48038 -1 var aria_required_attr_evaluate_default = ariaRequiredAttrEvaluate;48039 -1 function getOwnedRoles(virtualNode, required) {48040 -1 var ownedRoles = [];48041 -1 var ownedElements = get_owned_virtual_default(virtualNode);48042 -1 var _loop4 = function _loop4(_i16) {48043 -1 var ownedElement = ownedElements[_i16];48044 -1 var role = get_role_default(ownedElement, {48045 -1 noPresentational: true48046 -1 });48047 -1 if (!role || [ 'group', 'rowgroup' ].includes(role) && required.some(function(requiredRole) {48048 -1 return requiredRole === role;48049 -1 })) {48050 -1 ownedElements.push.apply(ownedElements, _toConsumableArray(ownedElement.children));48051 -1 } else if (role) {48052 -1 ownedRoles.push(role);-1 22806 function parseTextShadows(textShadow) { -1 22807 var current = { -1 22808 pixels: [] -1 22809 }; -1 22810 var str = textShadow.trim(); -1 22811 var shadows = [ current ]; -1 22812 if (!str) { -1 22813 return []; -1 22814 } -1 22815 while (str) { -1 22816 var colorMatch = str.match(/^rgba?\([0-9,.\s]+\)/i) || str.match(/^[a-z]+/i) || str.match(/^#[0-9a-f]+/i); -1 22817 var pixelMatch = str.match(/^([0-9.-]+)px/i) || str.match(/^(0)/); -1 22818 if (colorMatch) { -1 22819 assert_default(!current.colorStr, 'Multiple colors identified in text-shadow: '.concat(textShadow)); -1 22820 str = str.replace(colorMatch[0], '').trim(); -1 22821 current.colorStr = colorMatch[0]; -1 22822 } else if (pixelMatch) { -1 22823 assert_default(current.pixels.length < 3, 'Too many pixel units in text-shadow: '.concat(textShadow)); -1 22824 str = str.replace(pixelMatch[0], '').trim(); -1 22825 var pixelUnit = parseFloat((pixelMatch[1][0] === '.' ? '0' : '') + pixelMatch[1]); -1 22826 current.pixels.push(pixelUnit); -1 22827 } else if (str[0] === ',') { -1 22828 assert_default(current.pixels.length >= 2, 'Missing pixel value in text-shadow: '.concat(textShadow)); -1 22829 current = { -1 22830 pixels: [] -1 22831 }; -1 22832 shadows.push(current); -1 22833 str = str.substr(1).trim(); -1 22834 } else { -1 22835 throw new Error('Unable to process text-shadows: '.concat(textShadow)); 48053 22836 }48054 -1 };48055 -1 for (var _i16 = 0; _i16 < ownedElements.length; _i16++) {48056 -1 _loop4(_i16);48057 22837 }48058 -1 return ownedRoles;-1 22838 return shadows; 48059 22839 }48060 -1 function missingRequiredChildren(virtualNode, role, required, ownedRoles) {48061 -1 var isCombobox = role === 'combobox';48062 -1 if (isCombobox) {48063 -1 var textTypeInputs = [ 'text', 'search', 'email', 'url', 'tel' ];48064 -1 if (virtualNode.props.nodeName === 'input' && textTypeInputs.includes(virtualNode.props.type) || ownedRoles.includes('searchbox')) {48065 -1 required = required.filter(function(requiredRole) {48066 -1 return requiredRole !== 'textbox';48067 -1 });48068 -1 }48069 -1 var expandedChildRoles = [ 'listbox', 'tree', 'grid', 'dialog' ];48070 -1 var expandedValue = virtualNode.attr('aria-expanded');48071 -1 var expanded = expandedValue && expandedValue.toLowerCase() !== 'false';48072 -1 var popupRole = (virtualNode.attr('aria-haspopup') || 'listbox').toLowerCase();48073 -1 required = required.filter(function(requiredRole) {48074 -1 return !expandedChildRoles.includes(requiredRole) || expanded && requiredRole === popupRole;48075 -1 });48076 -1 }48077 -1 for (var _i17 = 0; _i17 < ownedRoles.length; _i17++) {48078 -1 var ownedRole = ownedRoles[_i17];48079 -1 if (required.includes(ownedRole)) {48080 -1 required = required.filter(function(requiredRole) {48081 -1 return requiredRole !== ownedRole;48082 -1 });48083 -1 if (!isCombobox) {48084 -1 return null;48085 -1 }48086 -1 }-1 22840 function textShadowColor(_ref57) { -1 22841 var colorStr = _ref57.colorStr, offsetX = _ref57.offsetX, offsetY = _ref57.offsetY, blurRadius = _ref57.blurRadius, fontSize = _ref57.fontSize; -1 22842 if (offsetX > blurRadius || offsetY > blurRadius) { -1 22843 return new color_default(0, 0, 0, 0); 48087 22844 }48088 -1 if (required.length) {48089 -1 return required;-1 22845 var shadowColor = new color_default(); -1 22846 shadowColor.parseString(colorStr); -1 22847 shadowColor.alpha *= blurRadiusToAlpha(blurRadius, fontSize); -1 22848 return shadowColor; -1 22849 } -1 22850 function blurRadiusToAlpha(blurRadius, fontSize) { -1 22851 if (blurRadius === 0) { -1 22852 return 1; 48090 22853 }48091 -1 return null;-1 22854 var relativeBlur = blurRadius / fontSize; -1 22855 return .185 / (relativeBlur + .4); 48092 22856 }48093 -1 function ariaRequiredChildrenEvaluate(node, options, virtualNode) {48094 -1 var reviewEmpty = options && Array.isArray(options.reviewEmpty) ? options.reviewEmpty : [];48095 -1 var role = get_explicit_role_default(virtualNode, {48096 -1 dpub: true-1 22857 var get_text_shadow_colors_default = getTextShadowColors; -1 22858 function _getBackgroundColor(elm) { -1 22859 var _bgColors; -1 22860 var bgElms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; -1 22861 var shadowOutlineEmMax = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .1; -1 22862 var bgColors = get_text_shadow_colors_default(elm, { -1 22863 minRatio: shadowOutlineEmMax 48097 22864 });48098 -1 var required = required_owned_default(role);48099 -1 if (required === null) {48100 -1 return true;-1 22865 if (bgColors.length) { -1 22866 bgColors = [ { -1 22867 color: bgColors.reduce(flatten_shadow_colors_default) -1 22868 } ]; 48101 22869 }48102 -1 var ownedRoles = getOwnedRoles(virtualNode, required);48103 -1 var missing = missingRequiredChildren(virtualNode, role, required, ownedRoles);48104 -1 if (!missing) {48105 -1 return true;-1 22870 var elmStack = get_background_stack_default(elm); -1 22871 (elmStack || []).some(function(bgElm) { -1 22872 var bgElmStyle = window.getComputedStyle(bgElm); -1 22873 var bgColor = get_own_background_color_default(bgElmStyle); -1 22874 if (elmPartiallyObscured(elm, bgElm, bgColor) || element_has_image_default(bgElm, bgElmStyle)) { -1 22875 bgColors = null; -1 22876 bgElms.push(bgElm); -1 22877 return true; -1 22878 } -1 22879 if (bgColor.alpha !== 0) { -1 22880 bgElms.push(bgElm); -1 22881 var blendMode = bgElmStyle.getPropertyValue('mix-blend-mode'); -1 22882 bgColors.unshift({ -1 22883 color: bgColor, -1 22884 blendMode: normalizeBlendMode(blendMode) -1 22885 }); -1 22886 return bgColor.alpha === 1; -1 22887 } else { -1 22888 return false; -1 22889 } -1 22890 }); -1 22891 if (bgColors === null || elmStack === null) { -1 22892 return null; 48106 22893 }48107 -1 this.data(missing);48108 -1 if (reviewEmpty.includes(role) && !has_content_virtual_default(virtualNode, false, true) && !ownedRoles.length && (!virtualNode.hasAttr('aria-owns') || !idrefs_default(node, 'aria-owns').length)) {48109 -1 return void 0;-1 22894 var pageBgs = getPageBackgroundColors(elm, elmStack.includes(document.body)); -1 22895 (_bgColors = bgColors).unshift.apply(_bgColors, _toConsumableArray(pageBgs)); -1 22896 if (bgColors.length === 0) { -1 22897 return new color_default(255, 255, 255, 1); 48110 22898 }48111 -1 return false;-1 22899 var blendedColor = bgColors.reduce(function(bgColor, fgColor) { -1 22900 return flatten_colors_default(fgColor.color, bgColor.color instanceof color_default ? bgColor.color : bgColor, fgColor.blendMode); -1 22901 }); -1 22902 return flatten_colors_default(blendedColor.color instanceof color_default ? blendedColor.color : blendedColor, new color_default(255, 255, 255, 1)); 48112 22903 }48113 -1 var aria_required_children_evaluate_default = ariaRequiredChildrenEvaluate;48114 -1 function getMissingContext(virtualNode, ownGroupRoles, reqContext, includeElement) {48115 -1 var explicitRole2 = get_explicit_role_default(virtualNode);48116 -1 if (!reqContext) {48117 -1 reqContext = required_context_default(explicitRole2);48118 -1 }48119 -1 if (!reqContext) {48120 -1 return null;-1 22904 function elmPartiallyObscured(elm, bgElm, bgColor) { -1 22905 var obscured = elm !== bgElm && !_visuallyContains(elm, bgElm) && bgColor.alpha !== 0; -1 22906 if (obscured) { -1 22907 incomplete_data_default.set('bgColor', 'elmPartiallyObscured'); 48121 22908 }48122 -1 var vNode = includeElement ? virtualNode : virtualNode.parent;48123 -1 while (vNode) {48124 -1 var parentRole = get_role_default(vNode);48125 -1 if (reqContext.includes('group') && parentRole === 'group') {48126 -1 if (ownGroupRoles.includes(explicitRole2)) {48127 -1 reqContext.push(explicitRole2);48128 -1 }48129 -1 vNode = vNode.parent;48130 -1 continue;-1 22909 return obscured; -1 22910 } -1 22911 function normalizeBlendMode(blendmode) { -1 22912 return !!blendmode ? blendmode : void 0; -1 22913 } -1 22914 function getPageBackgroundColors(elm, stackContainsBody) { -1 22915 var pageColors = []; -1 22916 if (!stackContainsBody) { -1 22917 var html = document.documentElement; -1 22918 var body = document.body; -1 22919 var htmlStyle = window.getComputedStyle(html); -1 22920 var bodyStyle = window.getComputedStyle(body); -1 22921 var htmlBgColor = get_own_background_color_default(htmlStyle); -1 22922 var bodyBgColor = get_own_background_color_default(bodyStyle); -1 22923 var bodyBgColorApplies = bodyBgColor.alpha !== 0 && _visuallyContains(elm, body); -1 22924 if (bodyBgColor.alpha !== 0 && htmlBgColor.alpha === 0 || bodyBgColorApplies && bodyBgColor.alpha !== 1) { -1 22925 pageColors.unshift({ -1 22926 color: bodyBgColor, -1 22927 blendMode: normalizeBlendMode(bodyStyle.getPropertyValue('mix-blend-mode')) -1 22928 }); 48131 22929 }48132 -1 if (reqContext.includes(parentRole)) {48133 -1 return null;48134 -1 } else if (parentRole && ![ 'presentation', 'none' ].includes(parentRole)) {48135 -1 return reqContext;-1 22930 if (htmlBgColor.alpha !== 0 && (!bodyBgColorApplies || bodyBgColorApplies && bodyBgColor.alpha !== 1)) { -1 22931 pageColors.unshift({ -1 22932 color: htmlBgColor, -1 22933 blendMode: normalizeBlendMode(htmlStyle.getPropertyValue('mix-blend-mode')) -1 22934 }); 48136 22935 }48137 -1 vNode = vNode.parent;48138 22936 }48139 -1 return reqContext;-1 22937 return pageColors; 48140 22938 }48141 -1 function getAriaOwners(element) {48142 -1 var owners = [], o = null;48143 -1 while (element) {48144 -1 if (element.getAttribute('id')) {48145 -1 var id = escape_selector_default(element.getAttribute('id'));48146 -1 var doc = get_root_node_default2(element);48147 -1 o = doc.querySelector('[aria-owns~='.concat(id, ']'));48148 -1 if (o) {48149 -1 owners.push(o);48150 -1 }48151 -1 }48152 -1 element = element.parentElement;-1 22939 function getContrast(bgColor, fgColor) { -1 22940 if (!fgColor || !bgColor) { -1 22941 return null; 48153 22942 }48154 -1 return owners.length ? owners : null;-1 22943 if (fgColor.alpha < 1) { -1 22944 fgColor = flatten_colors_default(fgColor, bgColor); -1 22945 } -1 22946 var bL = bgColor.getRelativeLuminance(); -1 22947 var fL = fgColor.getRelativeLuminance(); -1 22948 return (Math.max(fL, bL) + .05) / (Math.min(fL, bL) + .05); 48155 22949 }48156 -1 function ariaRequiredParentEvaluate(node, options, virtualNode) {48157 -1 var ownGroupRoles = options && Array.isArray(options.ownGroupRoles) ? options.ownGroupRoles : [];48158 -1 var missingParents = getMissingContext(virtualNode, ownGroupRoles);48159 -1 if (!missingParents) {48160 -1 return true;-1 22950 var get_contrast_default = getContrast; -1 22951 function getOpacity(node) { -1 22952 if (!node) { -1 22953 return 1; 48161 22954 }48162 -1 var owners = getAriaOwners(node);48163 -1 if (owners) {48164 -1 for (var _i18 = 0, l = owners.length; _i18 < l; _i18++) {48165 -1 missingParents = getMissingContext(get_node_from_tree_default(owners[_i18]), ownGroupRoles, missingParents, true);48166 -1 if (!missingParents) {48167 -1 return true;48168 -1 }48169 -1 }-1 22955 var vNode = get_node_from_tree_default(node); -1 22956 if (vNode && vNode._opacity !== void 0 && vNode._opacity !== null) { -1 22957 return vNode._opacity; 48170 22958 }48171 -1 this.data(missingParents);48172 -1 return false;-1 22959 var nodeStyle = window.getComputedStyle(node); -1 22960 var opacity = nodeStyle.getPropertyValue('opacity'); -1 22961 var finalOpacity = opacity * getOpacity(node.parentElement); -1 22962 if (vNode) { -1 22963 vNode._opacity = finalOpacity; -1 22964 } -1 22965 return finalOpacity; 48173 22966 }48174 -1 var aria_required_parent_evaluate_default = ariaRequiredParentEvaluate;48175 -1 function ariaRoledescriptionEvaluate(node) {48176 -1 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};48177 -1 var role = get_role_default(node);48178 -1 var supportedRoles = options.supportedRoles || [];48179 -1 if (supportedRoles.includes(role)) {48180 -1 return true;-1 22967 function getForegroundColor(node, _, bgColor) { -1 22968 var nodeStyle = window.getComputedStyle(node); -1 22969 var fgColor = new color_default(); -1 22970 fgColor.parseString(nodeStyle.getPropertyValue('color')); -1 22971 var opacity = getOpacity(node); -1 22972 fgColor.alpha = fgColor.alpha * opacity; -1 22973 if (fgColor.alpha === 1) { -1 22974 return fgColor; 48181 22975 }48182 -1 if (role && role !== 'presentation' && role !== 'none') {48183 -1 return void 0;-1 22976 if (!bgColor) { -1 22977 bgColor = _getBackgroundColor(node, []); 48184 22978 }48185 -1 return false;48186 -1 }48187 -1 var aria_roledescription_evaluate_default = ariaRoledescriptionEvaluate;48188 -1 function ariaUnsupportedAttrEvaluate(node, options, virtualNode) {48189 -1 var unsupportedAttrs = virtualNode.attrNames.filter(function(name) {48190 -1 var attribute = standards_default.ariaAttrs[name];48191 -1 if (!validate_attr_default(name)) {48192 -1 return false;48193 -1 }48194 -1 var unsupported4 = attribute.unsupported;48195 -1 if (_typeof(unsupported4) !== 'object') {48196 -1 return !!unsupported4;48197 -1 }48198 -1 return !matches_default3(node, unsupported4.exceptions);48199 -1 });48200 -1 if (unsupportedAttrs.length) {48201 -1 this.data(unsupportedAttrs);48202 -1 return true;-1 22979 if (bgColor === null) { -1 22980 var reason = incomplete_data_default.get('bgColor'); -1 22981 incomplete_data_default.set('fgColor', reason); -1 22982 return null; 48203 22983 }48204 -1 return false;48205 -1 }48206 -1 var aria_unsupported_attr_evaluate_default = ariaUnsupportedAttrEvaluate;48207 -1 function ariaValidAttrEvaluate(node, options, virtualNode) {48208 -1 options = Array.isArray(options.value) ? options.value : [];48209 -1 var invalid = [];48210 -1 var aria44 = /^aria-/;48211 -1 virtualNode.attrNames.forEach(function(attr) {48212 -1 if (options.indexOf(attr) === -1 && aria44.test(attr) && !validate_attr_default(attr)) {48213 -1 invalid.push(attr);48214 -1 }48215 -1 });48216 -1 if (invalid.length) {48217 -1 this.data(invalid);48218 -1 return false;-1 22984 if (fgColor.alpha < 1) { -1 22985 var textShadowColors = get_text_shadow_colors_default(node, { -1 22986 minRatio: 0 -1 22987 }); -1 22988 return [ fgColor ].concat(_toConsumableArray(textShadowColors), [ bgColor ]).reduce(flatten_shadow_colors_default); 48219 22989 }48220 -1 return true;-1 22990 return flatten_colors_default(fgColor, bgColor); 48221 22991 }48222 -1 var aria_valid_attr_evaluate_default = ariaValidAttrEvaluate;48223 -1 function ariaValidAttrValueEvaluate(node, options) {48224 -1 options = Array.isArray(options.value) ? options.value : [];48225 -1 var needsReview = '';48226 -1 var messageKey = '';48227 -1 var invalid = [];48228 -1 var aria44 = /^aria-/;48229 -1 var attrs = get_node_attributes_default(node);48230 -1 var skipAttrs = [ 'aria-errormessage' ];48231 -1 var preChecks = {48232 -1 'aria-controls': function ariaControls() {48233 -1 return node.getAttribute('aria-expanded') !== 'false' && node.getAttribute('aria-selected') !== 'false';48234 -1 },48235 -1 'aria-current': function ariaCurrent() {48236 -1 if (!validate_attr_value_default(node, 'aria-current')) {48237 -1 needsReview = 'aria-current="'.concat(node.getAttribute('aria-current'), '"');48238 -1 messageKey = 'ariaCurrent';48239 -1 }48240 -1 return;48241 -1 },48242 -1 'aria-owns': function ariaOwns() {48243 -1 return node.getAttribute('aria-expanded') !== 'false';48244 -1 },48245 -1 'aria-describedby': function ariaDescribedby() {48246 -1 if (!validate_attr_value_default(node, 'aria-describedby')) {48247 -1 needsReview = 'aria-describedby="'.concat(node.getAttribute('aria-describedby'), '"');48248 -1 messageKey = 'noId';48249 -1 }48250 -1 return;48251 -1 },48252 -1 'aria-labelledby': function ariaLabelledby() {48253 -1 if (!validate_attr_value_default(node, 'aria-labelledby')) {48254 -1 needsReview = 'aria-labelledby="'.concat(node.getAttribute('aria-labelledby'), '"');48255 -1 messageKey = 'noId';48256 -1 }48257 -1 }-1 22992 var get_foreground_color_default = getForegroundColor; -1 22993 function hasValidContrastRatio(bg, fg, fontSize, isBold) { -1 22994 var contrast = get_contrast_default(bg, fg); -1 22995 var isSmallFont = isBold && Math.ceil(fontSize * 72) / 96 < 14 || !isBold && Math.ceil(fontSize * 72) / 96 < 18; -1 22996 var expectedContrastRatio = isSmallFont ? 4.5 : 3; -1 22997 return { -1 22998 isValid: contrast > expectedContrastRatio, -1 22999 contrastRatio: contrast, -1 23000 expectedContrastRatio: expectedContrastRatio 48258 23001 };48259 -1 for (var _i19 = 0, l = attrs.length; _i19 < l; _i19++) {48260 -1 var attr = attrs[_i19];48261 -1 var attrName = attr.name;48262 -1 if (!skipAttrs.includes(attrName) && options.indexOf(attrName) === -1 && aria44.test(attrName) && (preChecks[attrName] ? preChecks[attrName]() : true) && !validate_attr_value_default(node, attrName)) {48263 -1 invalid.push(''.concat(attrName, '="').concat(attr.nodeValue, '"'));48264 -1 }-1 23002 } -1 23003 var has_valid_contrast_ratio_default = hasValidContrastRatio; -1 23004 function colorContrastEvaluate(node, options, virtualNode) { -1 23005 var ignoreUnicode = options.ignoreUnicode, ignoreLength = options.ignoreLength, ignorePseudo = options.ignorePseudo, boldValue = options.boldValue, boldTextPt = options.boldTextPt, largeTextPt = options.largeTextPt, contrastRatio = options.contrastRatio, shadowOutlineEmMax = options.shadowOutlineEmMax, pseudoSizeThreshold = options.pseudoSizeThreshold; -1 23006 if (!is_visible_default(node, false)) { -1 23007 this.data({ -1 23008 messageKey: 'hidden' -1 23009 }); -1 23010 return true; 48265 23011 }48266 -1 if (needsReview) {-1 23012 var visibleText = visible_virtual_default(virtualNode, false, true); -1 23013 if (ignoreUnicode && textIsEmojis(visibleText)) { 48267 23014 this.data({48268 -1 messageKey: messageKey,48269 -1 needsReview: needsReview-1 23015 messageKey: 'nonBmp' 48270 23016 }); 48271 23017 return void 0; 48272 23018 }48273 -1 if (invalid.length) {48274 -1 this.data(invalid);48275 -1 return false;-1 23019 var nodeStyle = window.getComputedStyle(node); -1 23020 var fontSize = parseFloat(nodeStyle.getPropertyValue('font-size')); -1 23021 var fontWeight = nodeStyle.getPropertyValue('font-weight'); -1 23022 var bold = parseFloat(fontWeight) >= boldValue || fontWeight === 'bold'; -1 23023 var ptSize = Math.ceil(fontSize * 72) / 96; -1 23024 var isSmallFont = bold && ptSize < boldTextPt || !bold && ptSize < largeTextPt; -1 23025 var _ref58 = isSmallFont ? contrastRatio.normal : contrastRatio.large, expected = _ref58.expected, minThreshold = _ref58.minThreshold, maxThreshold = _ref58.maxThreshold; -1 23026 var pseudoElm = findPseudoElement(virtualNode, { -1 23027 ignorePseudo: ignorePseudo, -1 23028 pseudoSizeThreshold: pseudoSizeThreshold -1 23029 }); -1 23030 if (pseudoElm) { -1 23031 this.data({ -1 23032 fontSize: ''.concat((fontSize * 72 / 96).toFixed(1), 'pt (').concat(fontSize, 'px)'), -1 23033 fontWeight: bold ? 'bold' : 'normal', -1 23034 messageKey: 'pseudoContent', -1 23035 expectedContrastRatio: expected + ':1' -1 23036 }); -1 23037 this.relatedNodes(pseudoElm.actualNode); -1 23038 return void 0; 48276 23039 }48277 -1 return true;48278 -1 }48279 -1 var aria_valid_attr_value_evaluate_default = ariaValidAttrValueEvaluate;48280 -1 function fallbackroleEvaluate(node, options, virtualNode) {48281 -1 return token_list_default(virtualNode.attr('role')).length > 1;48282 -1 }48283 -1 var fallbackrole_evaluate_default = fallbackroleEvaluate;48284 -1 function hasGlobalAriaAttributeEvaluate(node, options, virtualNode) {48285 -1 var globalAttrs = get_global_aria_attrs_default().filter(function(attr) {48286 -1 return virtualNode.hasAttr(attr);-1 23040 var bgNodes = []; -1 23041 var bgColor = _getBackgroundColor(node, bgNodes, shadowOutlineEmMax); -1 23042 var fgColor = get_foreground_color_default(node, false, bgColor); -1 23043 var shadowColors = get_text_shadow_colors_default(node, { -1 23044 minRatio: .001, -1 23045 maxRatio: shadowOutlineEmMax 48287 23046 });48288 -1 this.data(globalAttrs);48289 -1 return globalAttrs.length > 0;48290 -1 }48291 -1 var has_global_aria_attribute_evaluate_default = hasGlobalAriaAttributeEvaluate;48292 -1 function hasImplicitChromiumRoleMatches(node, virtualNode) {48293 -1 return implicit_role_default(virtualNode, {48294 -1 chromium: true48295 -1 }) !== null;48296 -1 }48297 -1 var has_implicit_chromium_role_matches_default = hasImplicitChromiumRoleMatches;48298 -1 function hasWidgetRoleEvaluate(node) {48299 -1 var role = node.getAttribute('role');48300 -1 if (role === null) {48301 -1 return false;-1 23047 var contrast = null; -1 23048 var contrastContributor = null; -1 23049 var shadowColor = null; -1 23050 if (shadowColors.length === 0) { -1 23051 contrast = get_contrast_default(bgColor, fgColor); -1 23052 } else if (fgColor && bgColor) { -1 23053 shadowColor = [].concat(_toConsumableArray(shadowColors), [ bgColor ]).reduce(flatten_shadow_colors_default); -1 23054 var fgBgContrast = get_contrast_default(bgColor, fgColor); -1 23055 var bgShContrast = get_contrast_default(bgColor, shadowColor); -1 23056 var fgShContrast = get_contrast_default(shadowColor, fgColor); -1 23057 contrast = Math.max(fgBgContrast, bgShContrast, fgShContrast); -1 23058 if (contrast !== fgBgContrast) { -1 23059 contrastContributor = bgShContrast > fgShContrast ? 'shadowOnBgColor' : 'fgOnShadowColor'; -1 23060 } 48302 23061 }48303 -1 var roleType = get_role_type_default(role);48304 -1 return roleType === 'widget' || roleType === 'composite';48305 -1 }48306 -1 var has_widget_role_evaluate_default = hasWidgetRoleEvaluate;48307 -1 function invalidroleEvaluate(node, options, virtualNode) {48308 -1 var allRoles = token_list_default(virtualNode.attr('role'));48309 -1 var allInvalid = allRoles.every(function(role) {48310 -1 return !is_valid_role_default(role, {48311 -1 allowAbstract: true-1 23062 var isValid = contrast > expected; -1 23063 if (typeof minThreshold === 'number' && contrast < minThreshold || typeof maxThreshold === 'number' && contrast > maxThreshold) { -1 23064 this.data({ -1 23065 contrastRatio: contrast 48312 23066 });48313 -1 });48314 -1 if (allInvalid) {48315 -1 this.data(allRoles);48316 23067 return true; 48317 23068 }48318 -1 return false;48319 -1 }48320 -1 var invalidrole_evaluate_default = invalidroleEvaluate;48321 -1 function isElementFocusableEvaluate(node, options, virtualNode) {48322 -1 return is_focusable_default(virtualNode);48323 -1 }48324 -1 var is_element_focusable_evaluate_default = isElementFocusableEvaluate;48325 -1 function noImplicitExplicitLabelEvaluate(node, options, virtualNode) {48326 -1 var role = get_role_default(virtualNode, {48327 -1 noImplicit: true48328 -1 });48329 -1 this.data(role);48330 -1 var label5;48331 -1 var accText;48332 -1 try {48333 -1 label5 = sanitize_default(label_text_default(virtualNode)).toLowerCase();48334 -1 accText = sanitize_default(accessible_text_virtual_default(virtualNode)).toLowerCase();48335 -1 } catch (e) {48336 -1 return void 0;48337 -1 }48338 -1 if (!accText && !label5) {48339 -1 return false;-1 23069 var truncatedResult = Math.floor(contrast * 100) / 100; -1 23070 var missing; -1 23071 if (bgColor === null) { -1 23072 missing = incomplete_data_default.get('bgColor'); -1 23073 } else if (!isValid) { -1 23074 missing = contrastContributor; 48340 23075 }48341 -1 if (!accText && label5) {48342 -1 return void 0;-1 23076 var equalRatio = truncatedResult === 1; -1 23077 var shortTextContent = visibleText.length === 1; -1 23078 if (equalRatio) { -1 23079 missing = incomplete_data_default.set('bgColor', 'equalRatio'); -1 23080 } else if (!isValid && shortTextContent && !ignoreLength) { -1 23081 missing = 'shortTextContent'; 48343 23082 }48344 -1 if (!accText.includes(label5)) {-1 23083 this.data({ -1 23084 fgColor: fgColor ? fgColor.toHexString() : void 0, -1 23085 bgColor: bgColor ? bgColor.toHexString() : void 0, -1 23086 contrastRatio: truncatedResult, -1 23087 fontSize: ''.concat((fontSize * 72 / 96).toFixed(1), 'pt (').concat(fontSize, 'px)'), -1 23088 fontWeight: bold ? 'bold' : 'normal', -1 23089 messageKey: missing, -1 23090 expectedContrastRatio: expected + ':1', -1 23091 shadowColor: shadowColor ? shadowColor.toHexString() : void 0 -1 23092 }); -1 23093 if (fgColor === null || bgColor === null || equalRatio || shortTextContent && !ignoreLength && !isValid) { -1 23094 missing = null; -1 23095 incomplete_data_default.clear(); -1 23096 this.relatedNodes(bgNodes); 48345 23097 return void 0; 48346 23098 }48347 -1 return false;48348 -1 }48349 -1 var no_implicit_explicit_label_evaluate_default = noImplicitExplicitLabelEvaluate;48350 -1 function unsupportedroleEvaluate(node, options, virtualNode) {48351 -1 return is_unsupported_role_default(get_role_default(virtualNode));48352 -1 }48353 -1 var unsupportedrole_evaluate_default = unsupportedroleEvaluate;48354 -1 var VALID_TAG_NAMES_FOR_SCROLLABLE_REGIONS = {48355 -1 ARTICLE: true,48356 -1 ASIDE: true,48357 -1 NAV: true,48358 -1 SECTION: true48359 -1 };48360 -1 var VALID_ROLES_FOR_SCROLLABLE_REGIONS = {48361 -1 application: true,48362 -1 banner: false,48363 -1 complementary: true,48364 -1 contentinfo: true,48365 -1 form: true,48366 -1 main: true,48367 -1 navigation: true,48368 -1 region: true,48369 -1 search: false48370 -1 };48371 -1 function validScrollableTagName(node) {48372 -1 var nodeName2 = node.nodeName.toUpperCase();48373 -1 return VALID_TAG_NAMES_FOR_SCROLLABLE_REGIONS[nodeName2] || false;48374 -1 }48375 -1 function validScrollableRole(node, options) {48376 -1 var role = get_explicit_role_default(node);48377 -1 if (!role) {48378 -1 return false;-1 23099 if (!isValid) { -1 23100 this.relatedNodes(bgNodes); 48379 23101 }48380 -1 return VALID_ROLES_FOR_SCROLLABLE_REGIONS[role] || options.roles.includes(role) || false;48381 -1 }48382 -1 function validScrollableSemanticsEvaluate(node, options) {48383 -1 return validScrollableRole(node, options) || validScrollableTagName(node);-1 23102 return isValid; 48384 23103 }48385 -1 var valid_scrollable_semantics_evaluate_default = validScrollableSemanticsEvaluate;48386 -1 var table_exports = {};48387 -1 __export(table_exports, {48388 -1 getAllCells: function getAllCells() {48389 -1 return get_all_cells_default;48390 -1 },48391 -1 getCellPosition: function getCellPosition() {48392 -1 return get_cell_position_default;48393 -1 },48394 -1 getHeaders: function getHeaders() {48395 -1 return get_headers_default;48396 -1 },48397 -1 getScope: function getScope() {48398 -1 return get_scope_default;48399 -1 },48400 -1 isColumnHeader: function isColumnHeader() {48401 -1 return is_column_header_default;48402 -1 },48403 -1 isDataCell: function isDataCell() {48404 -1 return is_data_cell_default;48405 -1 },48406 -1 isDataTable: function isDataTable() {48407 -1 return is_data_table_default;48408 -1 },48409 -1 isHeader: function isHeader() {48410 -1 return is_header_default;48411 -1 },48412 -1 isRowHeader: function isRowHeader() {48413 -1 return is_row_header_default;48414 -1 },48415 -1 toArray: function toArray() {48416 -1 return to_grid_default;48417 -1 },48418 -1 toGrid: function toGrid() {48419 -1 return to_grid_default;48420 -1 },48421 -1 traverse: function traverse() {48422 -1 return traverse_default;-1 23104 function findPseudoElement(vNode, _ref59) { -1 23105 var _ref59$pseudoSizeThre = _ref59.pseudoSizeThreshold, pseudoSizeThreshold = _ref59$pseudoSizeThre === void 0 ? .25 : _ref59$pseudoSizeThre, _ref59$ignorePseudo = _ref59.ignorePseudo, ignorePseudo = _ref59$ignorePseudo === void 0 ? false : _ref59$ignorePseudo; -1 23106 if (ignorePseudo) { -1 23107 return; 48423 23108 }48424 -1 });48425 -1 function getAllCells(tableElm) {48426 -1 var rowIndex, cellIndex, rowLength, cellLength;48427 -1 var cells = [];48428 -1 for (rowIndex = 0, rowLength = tableElm.rows.length; rowIndex < rowLength; rowIndex++) {48429 -1 for (cellIndex = 0, cellLength = tableElm.rows[rowIndex].cells.length; cellIndex < cellLength; cellIndex++) {48430 -1 cells.push(tableElm.rows[rowIndex].cells[cellIndex]);-1 23109 var rect = vNode.boundingClientRect; -1 23110 var minimumSize = rect.width * rect.height * pseudoSizeThreshold; -1 23111 do { -1 23112 var beforeSize = getPseudoElementArea(vNode.actualNode, ':before'); -1 23113 var afterSize = getPseudoElementArea(vNode.actualNode, ':after'); -1 23114 if (beforeSize + afterSize > minimumSize) { -1 23115 return vNode; 48431 23116 }48432 -1 }48433 -1 return cells;-1 23117 } while (vNode = vNode.parent); 48434 23118 }48435 -1 var get_all_cells_default = getAllCells;48436 -1 function traverseForHeaders(headerType, position, tableGrid) {48437 -1 var property = headerType === 'row' ? '_rowHeaders' : '_colHeaders';48438 -1 var predicate = headerType === 'row' ? is_row_header_default : is_column_header_default;48439 -1 var startCell = tableGrid[position.y][position.x];48440 -1 var colspan = startCell.colSpan - 1;48441 -1 var rowspanAttr = startCell.getAttribute('rowspan');48442 -1 var rowspanValue = parseInt(rowspanAttr) === 0 || startCell.rowspan === 0 ? tableGrid.length : startCell.rowSpan;48443 -1 var rowspan = rowspanValue - 1;48444 -1 var rowStart = position.y + rowspan;48445 -1 var colStart = position.x + colspan;48446 -1 var rowEnd = headerType === 'row' ? position.y : 0;48447 -1 var colEnd = headerType === 'row' ? 0 : position.x;48448 -1 var headers;48449 -1 var cells = [];48450 -1 for (var row = rowStart; row >= rowEnd && !headers; row--) {48451 -1 for (var col = colStart; col >= colEnd; col--) {48452 -1 var cell = tableGrid[row] ? tableGrid[row][col] : void 0;48453 -1 if (!cell) {48454 -1 continue;48455 -1 }48456 -1 var vNode = axe.utils.getNodeFromTree(cell);48457 -1 if (vNode[property]) {48458 -1 headers = vNode[property];48459 -1 break;48460 -1 }48461 -1 cells.push(cell);48462 -1 }-1 23119 var getPseudoElementArea = memoize_default(function getPseudoElementArea2(node, pseudo) { -1 23120 var style = window.getComputedStyle(node, pseudo); -1 23121 var matchPseudoStyle = function matchPseudoStyle(prop, value) { -1 23122 return style.getPropertyValue(prop) === value; -1 23123 }; -1 23124 if (matchPseudoStyle('content', 'none') || matchPseudoStyle('display', 'none') || matchPseudoStyle('visibility', 'hidden') || matchPseudoStyle('position', 'absolute') === false) { -1 23125 return 0; 48463 23126 }48464 -1 headers = (headers || []).concat(cells.filter(predicate));48465 -1 cells.forEach(function(tableCell) {48466 -1 var vNode = axe.utils.getNodeFromTree(tableCell);48467 -1 vNode[property] = headers;48468 -1 });48469 -1 return headers;48470 -1 }48471 -1 function getHeaders(cell, tableGrid) {48472 -1 if (cell.getAttribute('headers')) {48473 -1 var headers = idrefs_default(cell, 'headers');48474 -1 if (headers.filter(function(header) {48475 -1 return header;48476 -1 }).length) {48477 -1 return headers;48478 -1 }-1 23127 if (get_own_background_color_default(style).alpha === 0 && matchPseudoStyle('background-image', 'none')) { -1 23128 return 0; 48479 23129 }48480 -1 if (!tableGrid) {48481 -1 tableGrid = to_grid_default(find_up_default(cell, 'table'));-1 23130 var pseudoWidth = parseUnit(style.getPropertyValue('width')); -1 23131 var pseudoHeight = parseUnit(style.getPropertyValue('height')); -1 23132 if (pseudoWidth.unit !== 'px' || pseudoHeight.unit !== 'px') { -1 23133 return pseudoWidth.value === 0 || pseudoHeight.value === 0 ? 0 : Infinity; 48482 23134 }48483 -1 var position = get_cell_position_default(cell, tableGrid);48484 -1 var rowHeaders = traverseForHeaders('row', position, tableGrid);48485 -1 var colHeaders = traverseForHeaders('col', position, tableGrid);48486 -1 return [].concat(rowHeaders, colHeaders).reverse();-1 23135 return pseudoWidth.value * pseudoHeight.value; -1 23136 }); -1 23137 function textIsEmojis(visibleText) { -1 23138 var options = { -1 23139 nonBmp: true -1 23140 }; -1 23141 var hasUnicodeChars = has_unicode_default(visibleText, options); -1 23142 var hasNonUnicodeChars = sanitize_default(remove_unicode_default(visibleText, options)) === ''; -1 23143 return hasUnicodeChars && hasNonUnicodeChars; -1 23144 } -1 23145 function parseUnit(str) { -1 23146 var unitRegex = /^([0-9.]+)([a-z]+)$/i; -1 23147 var _ref60 = str.match(unitRegex) || [], _ref61 = _slicedToArray(_ref60, 3), _ref61$ = _ref61[1], value = _ref61$ === void 0 ? '' : _ref61$, _ref61$2 = _ref61[2], unit = _ref61$2 === void 0 ? '' : _ref61$2; -1 23148 return { -1 23149 value: parseFloat(value), -1 23150 unit: unit.toLowerCase() -1 23151 }; -1 23152 } -1 23153 function getContrast2(color1, color22) { -1 23154 var c1lum = color1.getRelativeLuminance(); -1 23155 var c2lum = color22.getRelativeLuminance(); -1 23156 return (Math.max(c1lum, c2lum) + .05) / (Math.min(c1lum, c2lum) + .05); -1 23157 } -1 23158 var blockLike2 = [ 'block', 'list-item', 'table', 'flex', 'grid', 'inline-block' ]; -1 23159 function isBlock2(elm) { -1 23160 var display = window.getComputedStyle(elm).getPropertyValue('display'); -1 23161 return blockLike2.indexOf(display) !== -1 || display.substr(0, 6) === 'table-'; 48487 23162 }48488 -1 var get_headers_default = getHeaders;48489 -1 function isDataCell(cell) {48490 -1 if (!cell.children.length && !cell.textContent.trim()) {-1 23163 function linkInTextBlockEvaluate(node) { -1 23164 if (isBlock2(node)) { 48491 23165 return false; 48492 23166 }48493 -1 var role = cell.getAttribute('role');48494 -1 if (is_valid_role_default(role)) {48495 -1 return [ 'cell', 'gridcell' ].includes(role);-1 23167 var parentBlock = get_composed_parent_default(node); -1 23168 while (parentBlock.nodeType === 1 && !isBlock2(parentBlock)) { -1 23169 parentBlock = get_composed_parent_default(parentBlock); -1 23170 } -1 23171 this.relatedNodes([ parentBlock ]); -1 23172 if (element_is_distinct_default(node, parentBlock)) { -1 23173 return true; 48496 23174 } else {48497 -1 return cell.nodeName.toUpperCase() === 'TD';-1 23175 var nodeColor, parentColor; -1 23176 nodeColor = get_foreground_color_default(node); -1 23177 parentColor = get_foreground_color_default(parentBlock); -1 23178 if (!nodeColor || !parentColor) { -1 23179 return void 0; -1 23180 } -1 23181 var contrast = getContrast2(nodeColor, parentColor); -1 23182 if (contrast === 1) { -1 23183 return true; -1 23184 } else if (contrast >= 3) { -1 23185 incomplete_data_default.set('fgColor', 'bgContrast'); -1 23186 this.data({ -1 23187 messageKey: incomplete_data_default.get('fgColor') -1 23188 }); -1 23189 incomplete_data_default.clear(); -1 23190 return void 0; -1 23191 } -1 23192 nodeColor = _getBackgroundColor(node); -1 23193 parentColor = _getBackgroundColor(parentBlock); -1 23194 if (!nodeColor || !parentColor || getContrast2(nodeColor, parentColor) >= 3) { -1 23195 var reason; -1 23196 if (!nodeColor || !parentColor) { -1 23197 reason = incomplete_data_default.get('bgColor'); -1 23198 } else { -1 23199 reason = 'bgContrast'; -1 23200 } -1 23201 incomplete_data_default.set('fgColor', reason); -1 23202 this.data({ -1 23203 messageKey: incomplete_data_default.get('fgColor') -1 23204 }); -1 23205 incomplete_data_default.clear(); -1 23206 return void 0; -1 23207 } 48498 23208 } -1 23209 return false; 48499 23210 }48500 -1 var is_data_cell_default = isDataCell;48501 -1 function isDataTable(node) {48502 -1 var role = (node.getAttribute('role') || '').toLowerCase();48503 -1 if ((role === 'presentation' || role === 'none') && !is_focusable_default(node)) {48504 -1 return false;48505 -1 }48506 -1 if (node.getAttribute('contenteditable') === 'true' || find_up_default(node, '[contenteditable="true"]')) {-1 23211 var link_in_text_block_evaluate_default = linkInTextBlockEvaluate; -1 23212 function autocompleteAppropriateEvaluate(node, options, virtualNode) { -1 23213 if (virtualNode.props.nodeName !== 'input') { 48507 23214 return true; 48508 23215 }48509 -1 if (role === 'grid' || role === 'treegrid' || role === 'table') {48510 -1 return true;-1 23216 var number = [ 'text', 'search', 'number', 'tel' ]; -1 23217 var url = [ 'text', 'search', 'url' ]; -1 23218 var allowedTypesMap = { -1 23219 bday: [ 'text', 'search', 'date' ], -1 23220 email: [ 'text', 'search', 'email' ], -1 23221 username: [ 'text', 'search', 'email' ], -1 23222 'street-address': [ 'text' ], -1 23223 tel: [ 'text', 'search', 'tel' ], -1 23224 'tel-country-code': [ 'text', 'search', 'tel' ], -1 23225 'tel-national': [ 'text', 'search', 'tel' ], -1 23226 'tel-area-code': [ 'text', 'search', 'tel' ], -1 23227 'tel-local': [ 'text', 'search', 'tel' ], -1 23228 'tel-local-prefix': [ 'text', 'search', 'tel' ], -1 23229 'tel-local-suffix': [ 'text', 'search', 'tel' ], -1 23230 'tel-extension': [ 'text', 'search', 'tel' ], -1 23231 'cc-number': number, -1 23232 'cc-exp': [ 'text', 'search', 'month', 'tel' ], -1 23233 'cc-exp-month': number, -1 23234 'cc-exp-year': number, -1 23235 'cc-csc': number, -1 23236 'transaction-amount': number, -1 23237 'bday-day': number, -1 23238 'bday-month': number, -1 23239 'bday-year': number, -1 23240 'new-password': [ 'text', 'search', 'password' ], -1 23241 'current-password': [ 'text', 'search', 'password' ], -1 23242 url: url, -1 23243 photo: url, -1 23244 impp: url -1 23245 }; -1 23246 if (_typeof(options) === 'object') { -1 23247 Object.keys(options).forEach(function(key) { -1 23248 if (!allowedTypesMap[key]) { -1 23249 allowedTypesMap[key] = []; -1 23250 } -1 23251 allowedTypesMap[key] = allowedTypesMap[key].concat(options[key]); -1 23252 }); 48511 23253 }48512 -1 if (get_role_type_default(role) === 'landmark') {-1 23254 var autocompleteAttr = virtualNode.attr('autocomplete'); -1 23255 var autocompleteTerms = autocompleteAttr.split(/\s+/g).map(function(term) { -1 23256 return term.toLowerCase(); -1 23257 }); -1 23258 var purposeTerm = autocompleteTerms[autocompleteTerms.length - 1]; -1 23259 if (_autocomplete.stateTerms.includes(purposeTerm)) { 48513 23260 return true; 48514 23261 }48515 -1 if (node.getAttribute('datatable') === '0') {48516 -1 return false;-1 23262 var allowedTypes = allowedTypesMap[purposeTerm]; -1 23263 var type = virtualNode.hasAttr('type') ? sanitize_default(virtualNode.attr('type')).toLowerCase() : 'text'; -1 23264 type = valid_input_type_default().includes(type) ? type : 'text'; -1 23265 if (typeof allowedTypes === 'undefined') { -1 23266 return type === 'text'; 48517 23267 }48518 -1 if (node.getAttribute('summary')) {48519 -1 return true;-1 23268 return allowedTypes.includes(type); -1 23269 } -1 23270 var autocomplete_appropriate_evaluate_default = autocompleteAppropriateEvaluate; -1 23271 function autocompleteValidEvaluate(node, options, virtualNode) { -1 23272 var autocomplete2 = virtualNode.attr('autocomplete') || ''; -1 23273 return is_valid_autocomplete_default(autocomplete2, options); -1 23274 } -1 23275 var autocomplete_valid_evaluate_default = autocompleteValidEvaluate; -1 23276 function attrNonSpaceContentEvaluate(node) { -1 23277 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; -1 23278 var vNode = arguments.length > 2 ? arguments[2] : undefined; -1 23279 if (!options.attribute || typeof options.attribute !== 'string') { -1 23280 throw new TypeError('attr-non-space-content requires options.attribute to be a string'); 48520 23281 }48521 -1 if (node.tHead || node.tFoot || node.caption) {48522 -1 return true;-1 23282 if (!vNode.hasAttr(options.attribute)) { -1 23283 this.data({ -1 23284 messageKey: 'noAttr' -1 23285 }); -1 23286 return false; 48523 23287 }48524 -1 for (var childIndex = 0, childLength = node.children.length; childIndex < childLength; childIndex++) {48525 -1 if (node.children[childIndex].nodeName.toUpperCase() === 'COLGROUP') {48526 -1 return true;48527 -1 }-1 23288 var attribute = vNode.attr(options.attribute); -1 23289 var attributeIsEmpty = !sanitize_default(attribute); -1 23290 if (attributeIsEmpty) { -1 23291 this.data({ -1 23292 messageKey: 'emptyAttr' -1 23293 }); -1 23294 return false; 48528 23295 }48529 -1 var cells = 0;48530 -1 var rowLength = node.rows.length;48531 -1 var row, cell;48532 -1 var hasBorder = false;48533 -1 for (var rowIndex = 0; rowIndex < rowLength; rowIndex++) {48534 -1 row = node.rows[rowIndex];48535 -1 for (var cellIndex = 0, cellLength = row.cells.length; cellIndex < cellLength; cellIndex++) {48536 -1 cell = row.cells[cellIndex];48537 -1 if (cell.nodeName.toUpperCase() === 'TH') {48538 -1 return true;48539 -1 }48540 -1 if (!hasBorder && (cell.offsetWidth !== cell.clientWidth || cell.offsetHeight !== cell.clientHeight)) {48541 -1 hasBorder = true;48542 -1 }48543 -1 if (cell.getAttribute('scope') || cell.getAttribute('headers') || cell.getAttribute('abbr')) {48544 -1 return true;48545 -1 }48546 -1 if ([ 'columnheader', 'rowheader' ].includes((cell.getAttribute('role') || '').toLowerCase())) {48547 -1 return true;48548 -1 }48549 -1 if (cell.children.length === 1 && cell.children[0].nodeName.toUpperCase() === 'ABBR') {48550 -1 return true;48551 -1 }48552 -1 cells++;48553 -1 }-1 23296 return true; -1 23297 } -1 23298 var attr_non_space_content_evaluate_default = attrNonSpaceContentEvaluate; -1 23299 function pageHasElmAfter(results) { -1 23300 var elmUsedAnywhere = results.some(function(frameResult) { -1 23301 return frameResult.result === true; -1 23302 }); -1 23303 if (elmUsedAnywhere) { -1 23304 results.forEach(function(result) { -1 23305 result.result = true; -1 23306 }); 48554 23307 }48555 -1 if (node.getElementsByTagName('table').length) {48556 -1 return false;-1 23308 return results; -1 23309 } -1 23310 var has_descendant_after_default = pageHasElmAfter; -1 23311 function hasDescendant(node, options, virtualNode) { -1 23312 if (!options || !options.selector || typeof options.selector !== 'string') { -1 23313 throw new TypeError('has-descendant requires options.selector to be a string'); 48557 23314 }48558 -1 if (rowLength < 2) {48559 -1 return false;-1 23315 var matchingElms = query_selector_all_filter_default(virtualNode, options.selector, function(vNode) { -1 23316 return is_visible_default(vNode.actualNode, true); -1 23317 }); -1 23318 this.relatedNodes(matchingElms.map(function(vNode) { -1 23319 return vNode.actualNode; -1 23320 })); -1 23321 return matchingElms.length > 0; -1 23322 } -1 23323 var has_descendant_evaluate_default = hasDescendant; -1 23324 function hasTextContentEvaluate(node, options, virtualNode) { -1 23325 try { -1 23326 return sanitize_default(subtree_text_default(virtualNode)) !== ''; -1 23327 } catch (e) { -1 23328 return void 0; 48560 23329 }48561 -1 var sampleRow = node.rows[Math.ceil(rowLength / 2)];48562 -1 if (sampleRow.cells.length === 1 && sampleRow.cells[0].colSpan === 1) {48563 -1 return false;-1 23330 } -1 23331 var has_text_content_evaluate_default = hasTextContentEvaluate; -1 23332 function matchesDefinitionEvaluate(_, options, virtualNode) { -1 23333 return matches_default3(virtualNode, options.matcher); -1 23334 } -1 23335 var matches_definition_evaluate_default = matchesDefinitionEvaluate; -1 23336 function pageNoDuplicateAfter(results) { -1 23337 return results.filter(function(checkResult) { -1 23338 return checkResult.data !== 'ignored'; -1 23339 }); -1 23340 } -1 23341 var page_no_duplicate_after_default = pageNoDuplicateAfter; -1 23342 function pageNoDuplicateEvaluate(node, options, virtualNode) { -1 23343 if (!options || !options.selector || typeof options.selector !== 'string') { -1 23344 throw new TypeError('page-no-duplicate requires options.selector to be a string'); 48564 23345 }48565 -1 if (sampleRow.cells.length >= 5) {48566 -1 return true;-1 23346 var key = 'page-no-duplicate;' + options.selector; -1 23347 if (cache_default.get(key)) { -1 23348 this.data('ignored'); -1 23349 return; 48567 23350 }48568 -1 if (hasBorder) {48569 -1 return true;-1 23351 cache_default.set(key, true); -1 23352 var elms = query_selector_all_filter_default(axe._tree[0], options.selector, function(elm) { -1 23353 return is_visible_default(elm.actualNode, true); -1 23354 }); -1 23355 if (typeof options.nativeScopeFilter === 'string') { -1 23356 elms = elms.filter(function(elm) { -1 23357 return elm.actualNode.hasAttribute('role') || !find_up_virtual_default(elm, options.nativeScopeFilter); -1 23358 }); 48570 23359 }48571 -1 var bgColor, bgImage;48572 -1 for (rowIndex = 0; rowIndex < rowLength; rowIndex++) {48573 -1 row = node.rows[rowIndex];48574 -1 if (bgColor && bgColor !== window.getComputedStyle(row).getPropertyValue('background-color')) {48575 -1 return true;48576 -1 } else {48577 -1 bgColor = window.getComputedStyle(row).getPropertyValue('background-color');-1 23360 this.relatedNodes(elms.filter(function(elm) { -1 23361 return elm !== virtualNode; -1 23362 }).map(function(elm) { -1 23363 return elm.actualNode; -1 23364 })); -1 23365 return elms.length <= 1; -1 23366 } -1 23367 var page_no_duplicate_evaluate_default = pageNoDuplicateEvaluate; -1 23368 function accesskeysAfter(results) { -1 23369 var seen = {}; -1 23370 return results.filter(function(r) { -1 23371 if (!r.data) { -1 23372 return false; 48578 23373 }48579 -1 if (bgImage && bgImage !== window.getComputedStyle(row).getPropertyValue('background-image')) {-1 23374 var key = r.data.toUpperCase(); -1 23375 if (!seen[key]) { -1 23376 seen[key] = r; -1 23377 r.relatedNodes = []; 48580 23378 return true;48581 -1 } else {48582 -1 bgImage = window.getComputedStyle(row).getPropertyValue('background-image');48583 23379 }48584 -1 }48585 -1 if (rowLength >= 20) {48586 -1 return true;48587 -1 }48588 -1 if (get_element_coordinates_default(node).width > get_viewport_size_default(window).width * .95) {48589 -1 return false;48590 -1 }48591 -1 if (cells < 10) {48592 -1 return false;48593 -1 }48594 -1 if (node.querySelector('object, embed, iframe, applet')) {-1 23380 seen[key].relatedNodes.push(r.relatedNodes[0]); 48595 23381 return false; -1 23382 }).map(function(r) { -1 23383 r.result = !!r.relatedNodes.length; -1 23384 return r; -1 23385 }); -1 23386 } -1 23387 var accesskeys_after_default = accesskeysAfter; -1 23388 function accesskeysEvaluate(node) { -1 23389 if (is_visible_default(node, false)) { -1 23390 this.data(node.getAttribute('accesskey')); -1 23391 this.relatedNodes([ node ]); 48596 23392 } 48597 23393 return true; 48598 23394 }48599 -1 var is_data_table_default = isDataTable;48600 -1 function isHeader(cell) {48601 -1 if (is_column_header_default(cell) || is_row_header_default(cell)) {48602 -1 return true;48603 -1 }48604 -1 if (cell.getAttribute('id')) {48605 -1 var id = escape_selector_default(cell.getAttribute('id'));48606 -1 return !!document.querySelector('[headers~="'.concat(id, '"]'));-1 23395 var accesskeys_evaluate_default = accesskeysEvaluate; -1 23396 function focusableContentEvaluate(node, options, virtualNode) { -1 23397 var tabbableElements = virtualNode.tabbableElements; -1 23398 if (!tabbableElements) { -1 23399 return false; 48607 23400 }48608 -1 return false;-1 23401 var tabbableContentElements = tabbableElements.filter(function(el) { -1 23402 return el !== virtualNode; -1 23403 }); -1 23404 return tabbableContentElements.length > 0; 48609 23405 }48610 -1 var is_header_default = isHeader;48611 -1 function traverseTable(dir, position, tableGrid, callback) {48612 -1 var result;48613 -1 var cell = tableGrid[position.y] ? tableGrid[position.y][position.x] : void 0;48614 -1 if (!cell) {48615 -1 return [];-1 23406 var focusable_content_evaluate_default = focusableContentEvaluate; -1 23407 function focusableDisabledEvaluate(node, options, virtualNode) { -1 23408 var elementsThatCanBeDisabled = [ 'BUTTON', 'FIELDSET', 'INPUT', 'SELECT', 'TEXTAREA' ]; -1 23409 var tabbableElements = virtualNode.tabbableElements; -1 23410 if (!tabbableElements || !tabbableElements.length) { -1 23411 return true; 48616 23412 }48617 -1 if (typeof callback === 'function') {48618 -1 result = callback(cell, position, tableGrid);48619 -1 if (result === true) {48620 -1 return [ cell ];-1 23413 var relatedNodes = tabbableElements.reduce(function(out, _ref62) { -1 23414 var el = _ref62.actualNode; -1 23415 var nodeName2 = el.nodeName.toUpperCase(); -1 23416 if (elementsThatCanBeDisabled.includes(nodeName2)) { -1 23417 out.push(el); 48621 23418 } -1 23419 return out; -1 23420 }, []); -1 23421 this.relatedNodes(relatedNodes); -1 23422 if (relatedNodes.length === 0 || is_modal_open_default()) { -1 23423 return true; 48622 23424 }48623 -1 result = traverseTable(dir, {48624 -1 x: position.x + dir.x,48625 -1 y: position.y + dir.y48626 -1 }, tableGrid, callback);48627 -1 result.unshift(cell);48628 -1 return result;-1 23425 return relatedNodes.every(function(related) { -1 23426 return related.onfocus; -1 23427 }) ? void 0 : false; 48629 23428 }48630 -1 function traverse(dir, startPos, tableGrid, callback) {48631 -1 if (Array.isArray(startPos)) {48632 -1 callback = tableGrid;48633 -1 tableGrid = startPos;48634 -1 startPos = {48635 -1 x: 0,48636 -1 y: 048637 -1 };-1 23429 var focusable_disabled_evaluate_default = focusableDisabledEvaluate; -1 23430 function focusableElementEvaluate(node, options, virtualNode) { -1 23431 if (virtualNode.hasAttr('contenteditable') && isContenteditable(virtualNode)) { -1 23432 return true; 48638 23433 }48639 -1 if (typeof dir === 'string') {48640 -1 switch (dir) {48641 -1 case 'left':48642 -1 dir = {48643 -1 x: -1,48644 -1 y: 048645 -1 };48646 -1 break;48647 -148648 -1 case 'up':48649 -1 dir = {48650 -1 x: 0,48651 -1 y: -148652 -1 };48653 -1 break;48654 -148655 -1 case 'right':48656 -1 dir = {48657 -1 x: 1,48658 -1 y: 048659 -1 };48660 -1 break;48661 -148662 -1 case 'down':48663 -1 dir = {48664 -1 x: 0,48665 -1 y: 148666 -1 };48667 -1 break;-1 23434 var isFocusable2 = virtualNode.isFocusable; -1 23435 var tabIndex = parseInt(virtualNode.attr('tabindex'), 10); -1 23436 tabIndex = !isNaN(tabIndex) ? tabIndex : null; -1 23437 return tabIndex ? isFocusable2 && tabIndex >= 0 : isFocusable2; -1 23438 function isContenteditable(vNode) { -1 23439 var contenteditable = vNode.attr('contenteditable'); -1 23440 if (contenteditable === 'true' || contenteditable === '') { -1 23441 return true; -1 23442 } -1 23443 if (contenteditable === 'false') { -1 23444 return false; -1 23445 } -1 23446 var ancestor = closest_default(virtualNode.parent, '[contenteditable]'); -1 23447 if (!ancestor) { -1 23448 return false; 48668 23449 } -1 23450 return isContenteditable(ancestor); 48669 23451 }48670 -1 return traverseTable(dir, {48671 -1 x: startPos.x + dir.x,48672 -1 y: startPos.y + dir.y48673 -1 }, tableGrid, callback);48674 23452 }48675 -1 var traverse_default = traverse;48676 -1 function captionFakedEvaluate(node) {48677 -1 var table5 = to_grid_default(node);48678 -1 var firstRow = table5[0];48679 -1 if (table5.length <= 1 || firstRow.length <= 1 || node.rows.length <= 1) {-1 23453 var focusable_element_evaluate_default = focusableElementEvaluate; -1 23454 function focusableModalOpenEvaluate(node, options, virtualNode) { -1 23455 var tabbableElements = virtualNode.tabbableElements.map(function(_ref63) { -1 23456 var actualNode = _ref63.actualNode; -1 23457 return actualNode; -1 23458 }); -1 23459 if (!tabbableElements || !tabbableElements.length) { 48680 23460 return true; 48681 23461 }48682 -1 return firstRow.reduce(function(out, curr, i) {48683 -1 return out || curr !== firstRow[i + 1] && firstRow[i + 1] !== void 0;48684 -1 }, false);48685 -1 }48686 -1 var caption_faked_evaluate_default = captionFakedEvaluate;48687 -1 function html5ScopeEvaluate(node) {48688 -1 if (!is_html5_default(document)) {48689 -1 return true;-1 23462 if (is_modal_open_default()) { -1 23463 this.relatedNodes(tabbableElements); -1 23464 return void 0; 48690 23465 }48691 -1 return node.nodeName.toUpperCase() === 'TH';48692 -1 }48693 -1 var html5_scope_evaluate_default = html5ScopeEvaluate;48694 -1 function sameCaptionSummaryEvaluate(node) {48695 -1 return !!(node.summary && node.caption) && node.summary.toLowerCase() === accessible_text_default(node.caption).toLowerCase();48696 -1 }48697 -1 var same_caption_summary_evaluate_default = sameCaptionSummaryEvaluate;48698 -1 function scopeValueEvaluate(node, options) {48699 -1 var value = node.getAttribute('scope').toLowerCase();48700 -1 return options.values.indexOf(value) !== -1;-1 23466 return true; 48701 23467 }48702 -1 var scope_value_evaluate_default = scopeValueEvaluate;48703 -1 function tdHasHeaderEvaluate(node) {48704 -1 var badCells = [];48705 -1 var cells = get_all_cells_default(node);48706 -1 var tableGrid = to_grid_default(node);48707 -1 cells.forEach(function(cell) {48708 -1 if (has_content_default(cell) && is_data_cell_default(cell) && !label_default2(cell)) {48709 -1 var hasHeaders = get_headers_default(cell, tableGrid).some(function(header) {48710 -1 return header !== null && !!has_content_default(header);48711 -1 });48712 -1 if (!hasHeaders) {48713 -1 badCells.push(cell);48714 -1 }48715 -1 }48716 -1 });48717 -1 if (badCells.length) {48718 -1 this.relatedNodes(badCells);-1 23468 var focusable_modal_open_evaluate_default = focusableModalOpenEvaluate; -1 23469 function focusableNoNameEvaluate(node, options, virtualNode) { -1 23470 var tabIndex = virtualNode.attr('tabindex'); -1 23471 var inFocusOrder = is_focusable_default(virtualNode) && tabIndex > -1; -1 23472 if (!inFocusOrder) { 48719 23473 return false; 48720 23474 }48721 -1 return true;-1 23475 try { -1 23476 return !accessible_text_virtual_default(virtualNode); -1 23477 } catch (e) { -1 23478 return void 0; -1 23479 } 48722 23480 }48723 -1 var td_has_header_evaluate_default = tdHasHeaderEvaluate;48724 -1 function tdHeadersAttrEvaluate(node) {48725 -1 var cells = [];48726 -1 var reviewCells = [];48727 -1 var badCells = [];48728 -1 for (var rowIndex = 0; rowIndex < node.rows.length; rowIndex++) {48729 -1 var row = node.rows[rowIndex];48730 -1 for (var cellIndex = 0; cellIndex < row.cells.length; cellIndex++) {48731 -1 cells.push(row.cells[cellIndex]);48732 -1 }-1 23481 var focusable_no_name_evaluate_default = focusableNoNameEvaluate; -1 23482 function focusableNotTabbableEvaluate(node, options, virtualNode) { -1 23483 var elementsThatCanBeDisabled = [ 'BUTTON', 'FIELDSET', 'INPUT', 'SELECT', 'TEXTAREA' ]; -1 23484 var tabbableElements = virtualNode.tabbableElements; -1 23485 if (!tabbableElements || !tabbableElements.length) { -1 23486 return true; 48733 23487 }48734 -1 var ids = cells.reduce(function(ids2, cell) {48735 -1 if (cell.getAttribute('id')) {48736 -1 ids2.push(cell.getAttribute('id'));-1 23488 var relatedNodes = tabbableElements.reduce(function(out, _ref64) { -1 23489 var el = _ref64.actualNode; -1 23490 var nodeName2 = el.nodeName.toUpperCase(); -1 23491 if (!elementsThatCanBeDisabled.includes(nodeName2)) { -1 23492 out.push(el); 48737 23493 }48738 -1 return ids2;-1 23494 return out; 48739 23495 }, []);48740 -1 cells.forEach(function(cell) {48741 -1 var isSelf = false;48742 -1 var notOfTable = false;48743 -1 if (!cell.hasAttribute('headers')) {48744 -1 return;48745 -1 }48746 -1 var headersAttr = cell.getAttribute('headers').trim();48747 -1 if (!headersAttr) {48748 -1 return reviewCells.push(cell);48749 -1 }48750 -1 var headers = token_list_default(headersAttr);48751 -1 if (headers.length !== 0) {48752 -1 if (cell.getAttribute('id')) {48753 -1 isSelf = headers.indexOf(cell.getAttribute('id').trim()) !== -1;48754 -1 }48755 -1 notOfTable = headers.some(function(header) {48756 -1 return !ids.includes(header);48757 -1 });48758 -1 if (isSelf || notOfTable) {48759 -1 badCells.push(cell);48760 -1 }-1 23496 this.relatedNodes(relatedNodes); -1 23497 if (relatedNodes.length === 0 || is_modal_open_default()) { -1 23498 return true; -1 23499 } -1 23500 return relatedNodes.every(function(related) { -1 23501 return related.onfocus; -1 23502 }) ? void 0 : false; -1 23503 } -1 23504 var focusable_not_tabbable_evaluate_default = focusableNotTabbableEvaluate; -1 23505 function focusableDescendants(vNode) { -1 23506 if (is_focusable_default(vNode)) { -1 23507 return true; -1 23508 } -1 23509 if (!vNode.children) { -1 23510 if (vNode.props.nodeType === 1) { -1 23511 throw new Error('Cannot determine children'); 48761 23512 }48762 -1 });48763 -1 if (badCells.length > 0) {48764 -1 this.relatedNodes(badCells);48765 23513 return false; 48766 23514 }48767 -1 if (reviewCells.length) {48768 -1 this.relatedNodes(reviewCells);-1 23515 return vNode.children.some(function(child) { -1 23516 return focusableDescendants(child); -1 23517 }); -1 23518 } -1 23519 function frameFocusableContentEvaluate(node, options, virtualNode) { -1 23520 if (!virtualNode.children) { -1 23521 return void 0; -1 23522 } -1 23523 try { -1 23524 return !virtualNode.children.some(function(child) { -1 23525 return focusableDescendants(child); -1 23526 }); -1 23527 } catch (e) { 48769 23528 return void 0; 48770 23529 }48771 -1 return true;48772 23530 }48773 -1 var td_headers_attr_evaluate_default = tdHeadersAttrEvaluate;48774 -1 function thHasDataCellsEvaluate(node) {48775 -1 var cells = get_all_cells_default(node);48776 -1 var checkResult = this;48777 -1 var reffedHeaders = [];48778 -1 cells.forEach(function(cell) {48779 -1 var headers2 = cell.getAttribute('headers');48780 -1 if (headers2) {48781 -1 reffedHeaders = reffedHeaders.concat(headers2.split(/\s+/));48782 -1 }48783 -1 var ariaLabel = cell.getAttribute('aria-labelledby');48784 -1 if (ariaLabel) {48785 -1 reffedHeaders = reffedHeaders.concat(ariaLabel.split(/\s+/));48786 -1 }48787 -1 });48788 -1 var headers = cells.filter(function(cell) {48789 -1 if (sanitize_default(cell.textContent) === '') {48790 -1 return false;48791 -1 }48792 -1 return cell.nodeName.toUpperCase() === 'TH' || [ 'rowheader', 'columnheader' ].indexOf(cell.getAttribute('role')) !== -1;-1 23531 var frame_focusable_content_evaluate_default = frameFocusableContentEvaluate; -1 23532 function landmarkIsTopLevelEvaluate(node) { -1 23533 var landmarks = get_aria_roles_by_type_default('landmark'); -1 23534 var parent = get_composed_parent_default(node); -1 23535 var nodeRole = get_role_default(node); -1 23536 this.data({ -1 23537 role: nodeRole 48793 23538 });48794 -1 var tableGrid = to_grid_default(node);48795 -1 var out = true;48796 -1 headers.forEach(function(header) {48797 -1 if (header.getAttribute('id') && reffedHeaders.includes(header.getAttribute('id'))) {48798 -1 return;48799 -1 }48800 -1 var pos = get_cell_position_default(header, tableGrid);48801 -1 var hasCell = false;48802 -1 if (is_column_header_default(header)) {48803 -1 hasCell = traverse_default('down', pos, tableGrid).find(function(cell) {48804 -1 return !is_column_header_default(cell) && get_headers_default(cell, tableGrid).includes(header);48805 -1 });48806 -1 }48807 -1 if (!hasCell && is_row_header_default(header)) {48808 -1 hasCell = traverse_default('right', pos, tableGrid).find(function(cell) {48809 -1 return !is_row_header_default(cell) && get_headers_default(cell, tableGrid).includes(header);48810 -1 });48811 -1 }48812 -1 if (!hasCell) {48813 -1 checkResult.relatedNodes(header);-1 23539 while (parent) { -1 23540 var role = parent.getAttribute('role'); -1 23541 if (!role && parent.nodeName.toUpperCase() !== 'FORM') { -1 23542 role = implicit_role_default(parent); 48814 23543 }48815 -1 out = out && hasCell;48816 -1 });48817 -1 return out ? true : void 0;48818 -1 }48819 -1 var th_has_data_cells_evaluate_default = thHasDataCellsEvaluate;48820 -1 function hiddenContentEvaluate(node, options, virtualNode) {48821 -1 var allowlist = [ 'SCRIPT', 'HEAD', 'TITLE', 'NOSCRIPT', 'STYLE', 'TEMPLATE' ];48822 -1 if (!allowlist.includes(node.nodeName.toUpperCase()) && has_content_virtual_default(virtualNode)) {48823 -1 var styles = window.getComputedStyle(node);48824 -1 if (styles.getPropertyValue('display') === 'none') {48825 -1 return void 0;48826 -1 } else if (styles.getPropertyValue('visibility') === 'hidden') {48827 -1 var parent = get_composed_parent_default(node);48828 -1 var parentStyle = parent && window.getComputedStyle(parent);48829 -1 if (!parentStyle || parentStyle.getPropertyValue('visibility') !== 'hidden') {48830 -1 return void 0;48831 -1 }-1 23544 if (role && landmarks.includes(role) && !(role === 'main' && nodeRole === 'complementary')) { -1 23545 return false; 48832 23546 } -1 23547 parent = get_composed_parent_default(parent); 48833 23548 } 48834 23549 return true; 48835 23550 }48836 -1 var hidden_content_evaluate_default = hiddenContentEvaluate;48837 -1 var color_exports = {};48838 -1 __export(color_exports, {48839 -1 Color: function Color() {48840 -1 return color_default;48841 -1 },48842 -1 centerPointOfRect: function centerPointOfRect() {48843 -1 return center_point_of_rect_default;48844 -1 },48845 -1 elementHasImage: function elementHasImage() {48846 -1 return element_has_image_default;48847 -1 },48848 -1 elementIsDistinct: function elementIsDistinct() {48849 -1 return element_is_distinct_default;48850 -1 },48851 -1 filteredRectStack: function filteredRectStack() {48852 -1 return filtered_rect_stack_default;48853 -1 },48854 -1 flattenColors: function flattenColors() {48855 -1 return flatten_colors_default;48856 -1 },48857 -1 getBackgroundColor: function getBackgroundColor() {48858 -1 return get_background_color_default;48859 -1 },48860 -1 getBackgroundStack: function getBackgroundStack() {48861 -1 return get_background_stack_default;48862 -1 },48863 -1 getContrast: function getContrast() {48864 -1 return get_contrast_default;48865 -1 },48866 -1 getForegroundColor: function getForegroundColor() {48867 -1 return get_foreground_color_default;48868 -1 },48869 -1 getOwnBackgroundColor: function getOwnBackgroundColor() {48870 -1 return get_own_background_color_default;48871 -1 },48872 -1 getRectStack: function getRectStack() {48873 -1 return get_rect_stack_default;48874 -1 },48875 -1 getTextShadowColors: function getTextShadowColors() {48876 -1 return get_text_shadow_colors_default;48877 -1 },48878 -1 hasValidContrastRatio: function hasValidContrastRatio() {48879 -1 return has_valid_contrast_ratio_default;48880 -1 },48881 -1 incompleteData: function incompleteData() {48882 -1 return incomplete_data_default;48883 -1 }48884 -1 });48885 -1 function centerPointOfRect(rect) {48886 -1 if (rect.left > window.innerWidth) {-1 23551 var landmark_is_top_level_evaluate_default = landmarkIsTopLevelEvaluate; -1 23552 function noFocusableContentEvaluate(node, options, virtualNode) { -1 23553 if (!virtualNode.children) { 48887 23554 return void 0; 48888 23555 }48889 -1 if (rect.top > window.innerHeight) {-1 23556 try { -1 23557 var focusableDescendants2 = getFocusableDescendants(virtualNode); -1 23558 if (!focusableDescendants2.length) { -1 23559 return true; -1 23560 } -1 23561 var notHiddenElements = focusableDescendants2.filter(usesUnreliableHidingStrategy); -1 23562 if (notHiddenElements.length > 0) { -1 23563 this.data({ -1 23564 messageKey: 'notHidden' -1 23565 }); -1 23566 this.relatedNodes(notHiddenElements); -1 23567 } else { -1 23568 this.relatedNodes(focusableDescendants2); -1 23569 } -1 23570 return false; -1 23571 } catch (e) { 48890 23572 return void 0; 48891 23573 }48892 -1 var x = Math.min(Math.ceil(rect.left + rect.width / 2), window.innerWidth - 1);48893 -1 var y = Math.min(Math.ceil(rect.top + rect.height / 2), window.innerHeight - 1);48894 -1 return {48895 -1 x: x,48896 -1 y: y48897 -1 };48898 23574 }48899 -1 var center_point_of_rect_default = centerPointOfRect;48900 -1 function _getFonts(style) {48901 -1 return style.getPropertyValue('font-family').split(/[,;]/g).map(function(font) {48902 -1 return font.trim().toLowerCase();-1 23575 function getFocusableDescendants(vNode) { -1 23576 if (!vNode.children) { -1 23577 if (vNode.props.nodeType === 1) { -1 23578 throw new Error('Cannot determine children'); -1 23579 } -1 23580 return []; -1 23581 } -1 23582 var retVal = []; -1 23583 vNode.children.forEach(function(child) { -1 23584 var role = get_role_default(child); -1 23585 if (get_role_type_default(role) === 'widget' && is_focusable_default(child)) { -1 23586 retVal.push(child); -1 23587 } else { -1 23588 retVal.push.apply(retVal, _toConsumableArray(getFocusableDescendants(child))); -1 23589 } 48903 23590 }); -1 23591 return retVal; 48904 23592 }48905 -1 function elementIsDistinct(node, ancestorNode) {48906 -1 var nodeStyle = window.getComputedStyle(node);48907 -1 if (nodeStyle.getPropertyValue('background-image') !== 'none') {48908 -1 return true;48909 -1 }48910 -1 var hasBorder = [ 'border-bottom', 'border-top', 'outline' ].reduce(function(result, edge) {48911 -1 var borderClr = new color_default();48912 -1 borderClr.parseString(nodeStyle.getPropertyValue(edge + '-color'));48913 -1 return result || nodeStyle.getPropertyValue(edge + '-style') !== 'none' && parseFloat(nodeStyle.getPropertyValue(edge + '-width')) > 0 && borderClr.alpha !== 0;48914 -1 }, false);48915 -1 if (hasBorder) {48916 -1 return true;-1 23593 function usesUnreliableHidingStrategy(vNode) { -1 23594 var tabIndex = parseInt(vNode.attr('tabindex'), 10); -1 23595 return !isNaN(tabIndex) && tabIndex < 0; -1 23596 } -1 23597 function tabindexEvaluate(node, options, virtualNode) { -1 23598 var tabIndex = parseInt(virtualNode.attr('tabindex'), 10); -1 23599 return isNaN(tabIndex) ? true : tabIndex <= 0; -1 23600 } -1 23601 var tabindex_evaluate_default = tabindexEvaluate; -1 23602 function altSpaceValueEvaluate(node, options, virtualNode) { -1 23603 var alt = virtualNode.attr('alt'); -1 23604 var isOnlySpace = /^\s+$/; -1 23605 return typeof alt === 'string' && isOnlySpace.test(alt); -1 23606 } -1 23607 var alt_space_value_evaluate_default = altSpaceValueEvaluate; -1 23608 function duplicateImgLabelEvaluate(node, options, virtualNode) { -1 23609 if ([ 'none', 'presentation' ].includes(get_role_default(virtualNode))) { -1 23610 return false; 48917 23611 }48918 -1 var parentStyle = window.getComputedStyle(ancestorNode);48919 -1 if (_getFonts(nodeStyle)[0] !== _getFonts(parentStyle)[0]) {48920 -1 return true;-1 23612 var parentVNode = closest_default(virtualNode, options.parentSelector); -1 23613 if (!parentVNode) { -1 23614 return false; 48921 23615 }48922 -1 var hasStyle = [ 'text-decoration-line', 'text-decoration-style', 'font-weight', 'font-style', 'font-size' ].reduce(function(result, cssProp) {48923 -1 return result || nodeStyle.getPropertyValue(cssProp) !== parentStyle.getPropertyValue(cssProp);48924 -1 }, false);48925 -1 var tDec = nodeStyle.getPropertyValue('text-decoration');48926 -1 if (tDec.split(' ').length < 3) {48927 -1 hasStyle = hasStyle || tDec !== parentStyle.getPropertyValue('text-decoration');-1 23616 var visibleText = visible_virtual_default(parentVNode, true).toLowerCase(); -1 23617 if (visibleText === '') { -1 23618 return false; 48928 23619 }48929 -1 return hasStyle;-1 23620 return visibleText === accessible_text_virtual_default(virtualNode).toLowerCase(); 48930 23621 }48931 -1 var element_is_distinct_default = elementIsDistinct;48932 -1 function getRectStack2(elm) {48933 -1 var boundingStack = get_element_stack_default(elm);48934 -1 var filteredArr = get_text_element_stack_default(elm);48935 -1 if (!filteredArr || filteredArr.length <= 1) {48936 -1 return [ boundingStack ];48937 -1 }48938 -1 if (filteredArr.some(function(stack) {48939 -1 return stack === void 0;48940 -1 })) {48941 -1 return null;-1 23622 var duplicate_img_label_evaluate_default = duplicateImgLabelEvaluate; -1 23623 function explicitEvaluate(node, options, virtualNode) { -1 23624 if (virtualNode.attr('id')) { -1 23625 if (!virtualNode.actualNode) { -1 23626 return void 0; -1 23627 } -1 23628 var root = get_root_node_default2(virtualNode.actualNode); -1 23629 var id = escape_selector_default(virtualNode.attr('id')); -1 23630 var labels = Array.from(root.querySelectorAll('label[for="'.concat(id, '"]'))); -1 23631 if (labels.length) { -1 23632 try { -1 23633 return labels.some(function(label5) { -1 23634 if (!is_visible_default(label5)) { -1 23635 return true; -1 23636 } else { -1 23637 return !!accessible_text_default(label5); -1 23638 } -1 23639 }); -1 23640 } catch (e) { -1 23641 return void 0; -1 23642 } -1 23643 } 48942 23644 }48943 -1 filteredArr.splice(0, 0, boundingStack);48944 -1 return filteredArr;-1 23645 return false; 48945 23646 }48946 -1 var get_rect_stack_default = getRectStack2;48947 -1 function filteredRectStack(elm) {48948 -1 var rectStack = get_rect_stack_default(elm);48949 -1 if (rectStack && rectStack.length === 1) {48950 -1 return rectStack[0];-1 23647 var explicit_evaluate_default = explicitEvaluate; -1 23648 function helpSameAsLabelEvaluate(node, options, virtualNode) { -1 23649 var labelText2 = label_virtual_default2(virtualNode), check4 = node.getAttribute('title'); -1 23650 if (!labelText2) { -1 23651 return false; 48951 23652 }48952 -1 if (rectStack && rectStack.length > 1) {48953 -1 var boundingStack = rectStack.shift();48954 -1 var isSame;48955 -1 rectStack.forEach(function(rectList, index) {48956 -1 if (index === 0) {48957 -1 return;48958 -1 }48959 -1 var rectA = rectStack[index - 1], rectB = rectStack[index];48960 -1 isSame = rectA.every(function(element, elementIndex) {48961 -1 return element === rectB[elementIndex];48962 -1 }) || boundingStack.includes(elm);48963 -1 });48964 -1 if (!isSame) {48965 -1 incomplete_data_default.set('bgColor', 'elmPartiallyObscuring');48966 -1 return null;-1 23653 if (!check4) { -1 23654 check4 = ''; -1 23655 if (node.getAttribute('aria-describedby')) { -1 23656 var ref = idrefs_default(node, 'aria-describedby'); -1 23657 check4 = ref.map(function(thing) { -1 23658 return thing ? accessible_text_default(thing) : ''; -1 23659 }).join(''); 48967 23660 }48968 -1 return rectStack[0];48969 23661 }48970 -1 incomplete_data_default.set('bgColor', 'outsideViewport');48971 -1 return null;48972 -1 }48973 -1 var filtered_rect_stack_default = filteredRectStack;48974 -1 function flattenColors(fgColor, bgColor) {48975 -1 var alpha = fgColor.alpha;48976 -1 var r = (1 - alpha) * bgColor.red + alpha * fgColor.red;48977 -1 var g = (1 - alpha) * bgColor.green + alpha * fgColor.green;48978 -1 var b = (1 - alpha) * bgColor.blue + alpha * fgColor.blue;48979 -1 var a = fgColor.alpha + bgColor.alpha * (1 - fgColor.alpha);48980 -1 return new color_default(r, g, b, a);-1 23662 return sanitize_default(check4) === sanitize_default(labelText2); 48981 23663 }48982 -1 var flatten_colors_default = flattenColors;48983 -1 function contentOverlapping(targetElement, bgNode) {48984 -1 var targetRect = targetElement.getClientRects()[0];48985 -1 var obscuringElements = shadow_elements_from_point_default(targetRect.left, targetRect.top);48986 -1 if (obscuringElements) {48987 -1 for (var i = 0; i < obscuringElements.length; i++) {48988 -1 if (obscuringElements[i] !== targetElement && obscuringElements[i] === bgNode) {48989 -1 return true;-1 23664 var help_same_as_label_evaluate_default = helpSameAsLabelEvaluate; -1 23665 function hiddenExplicitLabelEvaluate(node, options, virtualNode) { -1 23666 if (virtualNode.hasAttr('id')) { -1 23667 if (!virtualNode.actualNode) { -1 23668 return void 0; -1 23669 } -1 23670 var root = get_root_node_default2(node); -1 23671 var id = escape_selector_default(node.getAttribute('id')); -1 23672 var label5 = root.querySelector('label[for="'.concat(id, '"]')); -1 23673 if (label5 && !is_visible_default(label5, true)) { -1 23674 var name; -1 23675 try { -1 23676 name = accessible_text_virtual_default(virtualNode).trim(); -1 23677 } catch (e) { -1 23678 return void 0; 48990 23679 } -1 23680 var isNameEmpty = name === ''; -1 23681 return isNameEmpty; 48991 23682 } 48992 23683 } 48993 23684 return false; 48994 23685 }48995 -1 function calculateObscuringElement(elmIndex, elmStack, originalElm) {48996 -1 if (elmIndex > 0) {48997 -1 for (var i = elmIndex - 1; i >= 0; i--) {48998 -1 var bgElm = elmStack[i];48999 -1 if (contentOverlapping(originalElm, bgElm)) {49000 -1 return true;49001 -1 } else {49002 -1 elmStack.splice(i, 1);49003 -1 }-1 23686 var hidden_explicit_label_evaluate_default = hiddenExplicitLabelEvaluate; -1 23687 function implicitEvaluate(node, options, virtualNode) { -1 23688 try { -1 23689 var label5 = closest_default(virtualNode, 'label'); -1 23690 if (label5) { -1 23691 return !!accessible_text_virtual_default(label5, { -1 23692 inControlContext: true -1 23693 }); 49004 23694 } -1 23695 return false; -1 23696 } catch (e) { -1 23697 return void 0; 49005 23698 }49006 -1 return false;49007 23699 }49008 -1 function sortPageBackground(elmStack) {49009 -1 var bodyIndex = elmStack.indexOf(document.body);49010 -1 var bgNodes = elmStack;49011 -1 var sortBodyElement = bodyIndex > 1 || bodyIndex === -1;49012 -1 if (sortBodyElement && !element_has_image_default(document.documentElement) && get_own_background_color_default(window.getComputedStyle(document.documentElement)).alpha === 0) {49013 -1 if (bodyIndex > 1) {49014 -1 bgNodes.splice(bodyIndex, 1);49015 -1 }49016 -1 bgNodes.splice(elmStack.indexOf(document.documentElement), 1);49017 -1 bgNodes.push(document.body);-1 23700 var implicit_evaluate_default = implicitEvaluate; -1 23701 function isStringContained(compare, compareWith) { -1 23702 var curatedCompareWith = curateString(compareWith); -1 23703 var curatedCompare = curateString(compare); -1 23704 if (!curatedCompareWith || !curatedCompare) { -1 23705 return false; 49018 23706 }49019 -1 return bgNodes;-1 23707 return curatedCompareWith.includes(curatedCompare); 49020 23708 }49021 -1 function getBackgroundStack(elm) {49022 -1 var elmStack = filtered_rect_stack_default(elm);49023 -1 if (elmStack === null) {49024 -1 return null;-1 23709 function curateString(str) { -1 23710 var noUnicodeStr = remove_unicode_default(str, { -1 23711 emoji: true, -1 23712 nonBmp: true, -1 23713 punctuations: true -1 23714 }); -1 23715 return sanitize_default(noUnicodeStr); -1 23716 } -1 23717 function labelContentNameMismatchEvaluate(node, options, virtualNode) { -1 23718 var _ref65 = options || {}, pixelThreshold = _ref65.pixelThreshold, occuranceThreshold = _ref65.occuranceThreshold; -1 23719 var accText = accessible_text_default(node).toLowerCase(); -1 23720 if (is_human_interpretable_default(accText) < 1) { -1 23721 return void 0; 49025 23722 }49026 -1 elmStack = reduce_to_elements_below_floating_default(elmStack, elm);49027 -1 elmStack = sortPageBackground(elmStack);49028 -1 var elmIndex = elmStack.indexOf(elm);49029 -1 if (calculateObscuringElement(elmIndex, elmStack, elm)) {49030 -1 incomplete_data_default.set('bgColor', 'bgOverlap');49031 -1 return null;-1 23723 var visibleText = sanitize_default(subtree_text_default(virtualNode, { -1 23724 subtreeDescendant: true, -1 23725 ignoreIconLigature: true, -1 23726 pixelThreshold: pixelThreshold, -1 23727 occuranceThreshold: occuranceThreshold -1 23728 })).toLowerCase(); -1 23729 if (!visibleText) { -1 23730 return true; 49032 23731 }49033 -1 return elmIndex !== -1 ? elmStack : null;-1 23732 if (is_human_interpretable_default(visibleText) < 1) { -1 23733 if (isStringContained(visibleText, accText)) { -1 23734 return true; -1 23735 } -1 23736 return void 0; -1 23737 } -1 23738 return isStringContained(visibleText, accText); 49034 23739 }49035 -1 var get_background_stack_default = getBackgroundStack;49036 -1 function getTextShadowColors(node) {49037 -1 var _ref45 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, minRatio = _ref45.minRatio, maxRatio = _ref45.maxRatio;49038 -1 var style = window.getComputedStyle(node);49039 -1 var textShadow = style.getPropertyValue('text-shadow');49040 -1 if (textShadow === 'none') {49041 -1 return [];-1 23740 var label_content_name_mismatch_evaluate_default = labelContentNameMismatchEvaluate; -1 23741 function multipleLabelEvaluate(node) { -1 23742 var id = escape_selector_default(node.getAttribute('id')); -1 23743 var parent = node.parentNode; -1 23744 var root = get_root_node_default2(node); -1 23745 root = root.documentElement || root; -1 23746 var labels = Array.from(root.querySelectorAll('label[for="'.concat(id, '"]'))); -1 23747 if (labels.length) { -1 23748 labels = labels.filter(function(label5) { -1 23749 return is_visible_default(label5); -1 23750 }); 49042 23751 }49043 -1 var fontSizeStr = style.getPropertyValue('font-size');49044 -1 var fontSize = parseInt(fontSizeStr);49045 -1 assert_default(isNaN(fontSize) === false, 'Unable to determine font-size value '.concat(fontSizeStr));49046 -1 var shadowColors = [];49047 -1 var shadows = parseTextShadows(textShadow);49048 -1 shadows.forEach(function(_ref46) {49049 -1 var colorStr = _ref46.colorStr, pixels = _ref46.pixels;49050 -1 colorStr = colorStr || style.getPropertyValue('color');49051 -1 var _pixels = _slicedToArray(pixels, 3), offsetY = _pixels[0], offsetX = _pixels[1], _pixels$ = _pixels[2], blurRadius = _pixels$ === void 0 ? 0 : _pixels$;49052 -1 if ((!minRatio || blurRadius >= fontSize * minRatio) && (!maxRatio || blurRadius < fontSize * maxRatio)) {49053 -1 var color10 = textShadowColor({49054 -1 colorStr: colorStr,49055 -1 offsetY: offsetY,49056 -1 offsetX: offsetX,49057 -1 blurRadius: blurRadius,49058 -1 fontSize: fontSize49059 -1 });49060 -1 shadowColors.push(color10);-1 23752 while (parent) { -1 23753 if (parent.nodeName.toUpperCase() === 'LABEL' && labels.indexOf(parent) === -1) { -1 23754 labels.push(parent); 49061 23755 }49062 -1 });49063 -1 return shadowColors;49064 -1 }49065 -1 function parseTextShadows(textShadow) {49066 -1 var current = {49067 -1 pixels: []49068 -1 };49069 -1 var str = textShadow.trim();49070 -1 var shadows = [ current ];49071 -1 if (!str) {49072 -1 return [];-1 23756 parent = parent.parentNode; 49073 23757 }49074 -1 while (str) {49075 -1 var colorMatch = str.match(/^rgba?\([0-9,.\s]+\)/i) || str.match(/^[a-z]+/i) || str.match(/^#[0-9a-f]+/i);49076 -1 var pixelMatch = str.match(/^([0-9.-]+)px/i) || str.match(/^(0)/);49077 -1 if (colorMatch) {49078 -1 assert_default(!current.colorStr, 'Multiple colors identified in text-shadow: '.concat(textShadow));49079 -1 str = str.replace(colorMatch[0], '').trim();49080 -1 current.colorStr = colorMatch[0];49081 -1 } else if (pixelMatch) {49082 -1 assert_default(current.pixels.length < 3, 'Too many pixel units in text-shadow: '.concat(textShadow));49083 -1 str = str.replace(pixelMatch[0], '').trim();49084 -1 var pixelUnit = parseFloat((pixelMatch[1][0] === '.' ? '0' : '') + pixelMatch[1]);49085 -1 current.pixels.push(pixelUnit);49086 -1 } else if (str[0] === ',') {49087 -1 assert_default(current.pixels.length >= 2, 'Missing pixel value in text-shadow: '.concat(textShadow));49088 -1 current = {49089 -1 pixels: []49090 -1 };49091 -1 shadows.push(current);49092 -1 str = str.substr(1).trim();49093 -1 } else {49094 -1 throw new Error('Unable to process text-shadows: '.concat(textShadow));-1 23758 this.relatedNodes(labels); -1 23759 if (labels.length > 1) { -1 23760 var ATVisibleLabels = labels.filter(function(label5) { -1 23761 return is_visible_default(label5, true); -1 23762 }); -1 23763 if (ATVisibleLabels.length > 1) { -1 23764 return void 0; 49095 23765 } -1 23766 var labelledby = idrefs_default(node, 'aria-labelledby'); -1 23767 return !labelledby.includes(ATVisibleLabels[0]) ? void 0 : false; 49096 23768 }49097 -1 return shadows;-1 23769 return false; 49098 23770 }49099 -1 function textShadowColor(_ref47) {49100 -1 var colorStr = _ref47.colorStr, offsetX = _ref47.offsetX, offsetY = _ref47.offsetY, blurRadius = _ref47.blurRadius, fontSize = _ref47.fontSize;49101 -1 if (offsetX > blurRadius || offsetY > blurRadius) {49102 -1 return new color_default(0, 0, 0, 0);49103 -1 }49104 -1 var shadowColor = new color_default();49105 -1 shadowColor.parseString(colorStr);49106 -1 shadowColor.alpha *= blurRadiusToAlpha(blurRadius, fontSize);49107 -1 return shadowColor;-1 23771 var multiple_label_evaluate_default = multipleLabelEvaluate; -1 23772 function titleOnlyEvaluate(node, options, virtualNode) { -1 23773 var labelText2 = label_virtual_default2(virtualNode); -1 23774 var title = title_text_default(virtualNode); -1 23775 var ariaDescribedBy = virtualNode.attr('aria-describedby'); -1 23776 return !labelText2 && !!(title || ariaDescribedBy); 49108 23777 }49109 -1 function blurRadiusToAlpha(blurRadius, fontSize) {49110 -1 var relativeBlur = blurRadius / fontSize;49111 -1 return .185 / (relativeBlur + .4);-1 23778 var title_only_evaluate_default = titleOnlyEvaluate; -1 23779 function landmarkIsUniqueAfter(results) { -1 23780 var uniqueLandmarks = []; -1 23781 return results.filter(function(currentResult) { -1 23782 var findMatch = function findMatch(someResult) { -1 23783 return currentResult.data.role === someResult.data.role && currentResult.data.accessibleText === someResult.data.accessibleText; -1 23784 }; -1 23785 var matchedResult = uniqueLandmarks.find(findMatch); -1 23786 if (matchedResult) { -1 23787 matchedResult.result = false; -1 23788 matchedResult.relatedNodes.push(currentResult.relatedNodes[0]); -1 23789 return false; -1 23790 } -1 23791 uniqueLandmarks.push(currentResult); -1 23792 currentResult.relatedNodes = []; -1 23793 return true; -1 23794 }); 49112 23795 }49113 -1 var get_text_shadow_colors_default = getTextShadowColors;49114 -1 function elmPartiallyObscured(elm, bgElm, bgColor) {49115 -1 var obscured = elm !== bgElm && !visually_contains_default(elm, bgElm) && bgColor.alpha !== 0;49116 -1 if (obscured) {49117 -1 incomplete_data_default.set('bgColor', 'elmPartiallyObscured');49118 -1 }49119 -1 return obscured;-1 23796 var landmark_is_unique_after_default = landmarkIsUniqueAfter; -1 23797 function landmarkIsUniqueEvaluate(node, options, virtualNode) { -1 23798 var role = get_role_default(node); -1 23799 var accessibleText2 = accessible_text_virtual_default(virtualNode); -1 23800 accessibleText2 = accessibleText2 ? accessibleText2.toLowerCase() : null; -1 23801 this.data({ -1 23802 role: role, -1 23803 accessibleText: accessibleText2 -1 23804 }); -1 23805 this.relatedNodes([ node ]); -1 23806 return true; -1 23807 } -1 23808 var landmark_is_unique_evaluate_default = landmarkIsUniqueEvaluate; -1 23809 function hasValue(value) { -1 23810 return (value || '').trim() !== ''; 49120 23811 }49121 -1 function getBackgroundColor(elm) {49122 -1 var bgElms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];49123 -1 var shadowOutlineEmMax = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .1;49124 -1 var bgColors = get_text_shadow_colors_default(elm, {49125 -1 minRatio: shadowOutlineEmMax-1 23812 function hasLangEvaluate(node, options, virtualNode) { -1 23813 var xhtml2 = typeof document !== 'undefined' ? is_xhtml_default(document) : false; -1 23814 if (options.attributes.includes('xml:lang') && options.attributes.includes('lang') && hasValue(virtualNode.attr('xml:lang')) && !hasValue(virtualNode.attr('lang')) && !xhtml2) { -1 23815 this.data({ -1 23816 messageKey: 'noXHTML' -1 23817 }); -1 23818 return false; -1 23819 } -1 23820 var hasLang = options.attributes.some(function(name) { -1 23821 return hasValue(virtualNode.attr(name)); 49126 23822 });49127 -1 var elmStack = get_background_stack_default(elm);49128 -1 (elmStack || []).some(function(bgElm) {49129 -1 var bgElmStyle = window.getComputedStyle(bgElm);49130 -1 var bgColor = get_own_background_color_default(bgElmStyle);49131 -1 if (elmPartiallyObscured(elm, bgElm, bgColor) || element_has_image_default(bgElm, bgElmStyle)) {49132 -1 bgColors = null;49133 -1 bgElms.push(bgElm);49134 -1 return true;-1 23823 if (!hasLang) { -1 23824 this.data({ -1 23825 messageKey: 'noLang' -1 23826 }); -1 23827 return false; -1 23828 } -1 23829 return true; -1 23830 } -1 23831 var has_lang_evaluate_default = hasLangEvaluate; -1 23832 function validLangEvaluate(node, options, virtualNode) { -1 23833 var invalid = []; -1 23834 options.attributes.forEach(function(langAttr) { -1 23835 var langVal = virtualNode.attr(langAttr); -1 23836 if (typeof langVal !== 'string') { -1 23837 return; 49135 23838 }49136 -1 if (bgColor.alpha !== 0) {49137 -1 bgElms.push(bgElm);49138 -1 bgColors.push(bgColor);49139 -1 return bgColor.alpha === 1;49140 -1 } else {49141 -1 return false;-1 23839 var baselangVal = get_base_lang_default(langVal); -1 23840 var invalidLang = options.value ? !options.value.map(get_base_lang_default).includes(baselangVal) : !valid_langs_default(baselangVal); -1 23841 if (baselangVal !== '' && invalidLang || langVal !== '' && !sanitize_default(langVal)) { -1 23842 invalid.push(langAttr + '="' + virtualNode.attr(langAttr) + '"'); 49142 23843 } 49143 23844 });49144 -1 if (bgColors === null || elmStack === null) {49145 -1 return null;-1 23845 if (invalid.length) { -1 23846 this.data(invalid); -1 23847 return true; 49146 23848 }49147 -1 bgColors.push(new color_default(255, 255, 255, 1));49148 -1 var colors = bgColors.reduce(flatten_colors_default);49149 -1 return colors;-1 23849 return false; 49150 23850 }49151 -1 var get_background_color_default = getBackgroundColor;49152 -1 function getContrast(bgColor, fgColor) {49153 -1 if (!fgColor || !bgColor) {49154 -1 return null;49155 -1 }49156 -1 if (fgColor.alpha < 1) {49157 -1 fgColor = flatten_colors_default(fgColor, bgColor);49158 -1 }49159 -1 var bL = bgColor.getRelativeLuminance();49160 -1 var fL = fgColor.getRelativeLuminance();49161 -1 return (Math.max(fL, bL) + .05) / (Math.min(fL, bL) + .05);-1 23851 var valid_lang_evaluate_default = validLangEvaluate; -1 23852 function xmlLangMismatchEvaluate(node, options, vNode) { -1 23853 var primaryLangValue = get_base_lang_default(vNode.attr('lang')); -1 23854 var primaryXmlLangValue = get_base_lang_default(vNode.attr('xml:lang')); -1 23855 return primaryLangValue === primaryXmlLangValue; 49162 23856 }49163 -1 var get_contrast_default = getContrast;49164 -1 function getOpacity(node) {49165 -1 if (!node) {49166 -1 return 1;-1 23857 var xml_lang_mismatch_evaluate_default = xmlLangMismatchEvaluate; -1 23858 function dlitemEvaluate(node) { -1 23859 var parent = get_composed_parent_default(node); -1 23860 var parentTagName = parent.nodeName.toUpperCase(); -1 23861 var parentRole = get_explicit_role_default(parent); -1 23862 if (parentTagName === 'DIV' && [ 'presentation', 'none', null ].includes(parentRole)) { -1 23863 parent = get_composed_parent_default(parent); -1 23864 parentTagName = parent.nodeName.toUpperCase(); -1 23865 parentRole = get_explicit_role_default(parent); 49167 23866 }49168 -1 var vNode = get_node_from_tree_default(node);49169 -1 if (vNode && vNode._opacity !== void 0 && vNode._opacity !== null) {49170 -1 return vNode._opacity;-1 23867 if (parentTagName !== 'DL') { -1 23868 return false; 49171 23869 }49172 -1 var nodeStyle = window.getComputedStyle(node);49173 -1 var opacity = nodeStyle.getPropertyValue('opacity');49174 -1 var finalOpacity = opacity * getOpacity(node.parentElement);49175 -1 if (vNode) {49176 -1 vNode._opacity = finalOpacity;-1 23870 if (!parentRole || [ 'presentation', 'none', 'list' ].includes(parentRole)) { -1 23871 return true; 49177 23872 }49178 -1 return finalOpacity;-1 23873 return false; 49179 23874 }49180 -1 function getForegroundColor(node, _, bgColor) {49181 -1 var nodeStyle = window.getComputedStyle(node);49182 -1 var fgColor = new color_default();49183 -1 fgColor.parseString(nodeStyle.getPropertyValue('color'));49184 -1 var opacity = getOpacity(node);49185 -1 fgColor.alpha = fgColor.alpha * opacity;49186 -1 if (fgColor.alpha === 1) {49187 -1 return fgColor;-1 23875 var dlitem_evaluate_default = dlitemEvaluate; -1 23876 function listitemEvaluate(node, options, virtualNode) { -1 23877 var parent = virtualNode.parent; -1 23878 if (!parent) { -1 23879 return void 0; 49188 23880 }49189 -1 if (!bgColor) {49190 -1 bgColor = get_background_color_default(node, []);-1 23881 var parentNodeName = parent.props.nodeName; -1 23882 var parentRole = get_explicit_role_default(parent); -1 23883 if ([ 'presentation', 'none', 'list' ].includes(parentRole)) { -1 23884 return true; 49191 23885 }49192 -1 if (bgColor === null) {49193 -1 var reason = incomplete_data_default.get('bgColor');49194 -1 incomplete_data_default.set('fgColor', reason);49195 -1 return null;-1 23886 if (parentRole && is_valid_role_default(parentRole)) { -1 23887 this.data({ -1 23888 messageKey: 'roleNotValid' -1 23889 }); -1 23890 return false; 49196 23891 }49197 -1 return flatten_colors_default(fgColor, bgColor);-1 23892 return [ 'ul', 'ol', 'menu' ].includes(parentNodeName); 49198 23893 }49199 -1 var get_foreground_color_default = getForegroundColor;49200 -1 function hasValidContrastRatio(bg, fg, fontSize, isBold) {49201 -1 var contrast = get_contrast_default(bg, fg);49202 -1 var isSmallFont = isBold && Math.ceil(fontSize * 72) / 96 < 14 || !isBold && Math.ceil(fontSize * 72) / 96 < 18;49203 -1 var expectedContrastRatio = isSmallFont ? 4.5 : 3;49204 -1 return {49205 -1 isValid: contrast > expectedContrastRatio,49206 -1 contrastRatio: contrast,49207 -1 expectedContrastRatio: expectedContrastRatio-1 23894 function onlyDlitemsEvaluate(node, options, virtualNode) { -1 23895 var ALLOWED_ROLES = [ 'definition', 'term', 'list' ]; -1 23896 var base = { -1 23897 badNodes: [], -1 23898 hasNonEmptyTextNode: false 49208 23899 }; -1 23900 var content = virtualNode.children.reduce(function(content2, child) { -1 23901 var actualNode = child.actualNode; -1 23902 if (actualNode.nodeName.toUpperCase() === 'DIV' && get_role_default(actualNode) === null) { -1 23903 return content2.concat(child.children); -1 23904 } -1 23905 return content2.concat(child); -1 23906 }, []); -1 23907 var result = content.reduce(function(out, childNode) { -1 23908 var actualNode = childNode.actualNode; -1 23909 var tagName = actualNode.nodeName.toUpperCase(); -1 23910 if (actualNode.nodeType === 1 && is_visible_default(actualNode, true, false)) { -1 23911 var explicitRole2 = get_explicit_role_default(actualNode); -1 23912 if (tagName !== 'DT' && tagName !== 'DD' || explicitRole2) { -1 23913 if (!ALLOWED_ROLES.includes(explicitRole2)) { -1 23914 out.badNodes.push(actualNode); -1 23915 } -1 23916 } -1 23917 } else if (actualNode.nodeType === 3 && actualNode.nodeValue.trim() !== '') { -1 23918 out.hasNonEmptyTextNode = true; -1 23919 } -1 23920 return out; -1 23921 }, base); -1 23922 if (result.badNodes.length) { -1 23923 this.relatedNodes(result.badNodes); -1 23924 } -1 23925 return !!result.badNodes.length || result.hasNonEmptyTextNode; 49209 23926 }49210 -1 var has_valid_contrast_ratio_default = hasValidContrastRatio;49211 -1 var hasPsuedoElement = memoize_default(function hasPsuedoElement2(node, pseudo) {49212 -1 var style = window.getComputedStyle(node, pseudo);49213 -1 var backgroundColor = get_own_background_color_default(style);49214 -1 return style.getPropertyValue('content') !== 'none' && style.getPropertyValue('position') === 'absolute' && parseInt(style.getPropertyValue('width')) !== 0 && parseInt(style.getPropertyValue('height')) !== 0 && (backgroundColor.alpha !== 0 || style.getPropertyValue('background-image') !== 'none');49215 -1 });49216 -1 function colorContrastEvaluate(node, options, virtualNode) {49217 -1 if (!is_visible_default(node, false)) {-1 23927 var only_dlitems_evaluate_default = onlyDlitemsEvaluate; -1 23928 function onlyListitemsEvaluate(node, options, virtualNode) { -1 23929 var hasNonEmptyTextNode = false; -1 23930 var atLeastOneListitem = false; -1 23931 var isEmpty = true; -1 23932 var badNodes = []; -1 23933 var badRoleNodes = []; -1 23934 var badRoles = []; -1 23935 virtualNode.children.forEach(function(vNode) { -1 23936 var actualNode = vNode.actualNode; -1 23937 if (actualNode.nodeType === 3 && actualNode.nodeValue.trim() !== '') { -1 23938 hasNonEmptyTextNode = true; -1 23939 return; -1 23940 } -1 23941 if (actualNode.nodeType !== 1 || !is_visible_default(actualNode, true, false)) { -1 23942 return; -1 23943 } -1 23944 isEmpty = false; -1 23945 var isLi = actualNode.nodeName.toUpperCase() === 'LI'; -1 23946 var role = get_role_default(vNode); -1 23947 var isListItemRole = role === 'listitem'; -1 23948 if (!isLi && !isListItemRole) { -1 23949 badNodes.push(actualNode); -1 23950 } -1 23951 if (isLi && !isListItemRole) { -1 23952 badRoleNodes.push(actualNode); -1 23953 if (!badRoles.includes(role)) { -1 23954 badRoles.push(role); -1 23955 } -1 23956 } -1 23957 if (isListItemRole) { -1 23958 atLeastOneListitem = true; -1 23959 } -1 23960 }); -1 23961 if (hasNonEmptyTextNode || badNodes.length) { -1 23962 this.relatedNodes(badNodes); 49218 23963 return true; 49219 23964 }49220 -1 var ignoreUnicode = options.ignoreUnicode, ignoreLength = options.ignoreLength, boldValue = options.boldValue, boldTextPt = options.boldTextPt, largeTextPt = options.largeTextPt, contrastRatio = options.contrastRatio, shadowOutlineEmMax = options.shadowOutlineEmMax;49221 -1 var visibleText = visible_virtual_default(virtualNode, false, true);49222 -1 var textContainsOnlyUnicode = has_unicode_default(visibleText, {49223 -1 nonBmp: true49224 -1 }) && sanitize_default(remove_unicode_default(visibleText, {49225 -1 nonBmp: true49226 -1 })) === '';49227 -1 if (textContainsOnlyUnicode && ignoreUnicode) {49228 -1 this.data({49229 -1 messageKey: 'nonBmp'49230 -1 });49231 -1 return void 0;-1 23965 if (isEmpty || atLeastOneListitem) { -1 23966 return false; 49232 23967 }49233 -1 var bgNodes = [];49234 -1 var bgColor = get_background_color_default(node, bgNodes, shadowOutlineEmMax);49235 -1 var fgColor = get_foreground_color_default(node, false, bgColor);49236 -1 var shadowColors = get_text_shadow_colors_default(node, {49237 -1 maxRatio: shadowOutlineEmMax-1 23968 this.relatedNodes(badRoleNodes); -1 23969 this.data({ -1 23970 messageKey: 'roleNotValid', -1 23971 roles: badRoles.join(', ') 49238 23972 });49239 -1 var nodeStyle = window.getComputedStyle(node);49240 -1 var fontSize = parseFloat(nodeStyle.getPropertyValue('font-size'));49241 -1 var fontWeight = nodeStyle.getPropertyValue('font-weight');49242 -1 var bold = parseFloat(fontWeight) >= boldValue || fontWeight === 'bold';49243 -1 var contrast = null;49244 -1 if (shadowColors.length === 0) {49245 -1 contrast = get_contrast_default(bgColor, fgColor);49246 -1 } else if (fgColor && bgColor) {49247 -1 var shadowColor = [].concat(_toConsumableArray(shadowColors), [ bgColor ]).reduce(flatten_colors_default);49248 -1 var bgContrast = get_contrast_default(bgColor, shadowColor);49249 -1 var fgContrast = get_contrast_default(shadowColor, fgColor);49250 -1 contrast = Math.max(bgContrast, fgContrast);-1 23973 return true; -1 23974 } -1 23975 var only_listitems_evaluate_default = onlyListitemsEvaluate; -1 23976 function structuredDlitemsEvaluate(node, options, virtualNode) { -1 23977 var children = virtualNode.children; -1 23978 if (!children || !children.length) { -1 23979 return false; 49251 23980 }49252 -1 var ptSize = Math.ceil(fontSize * 72) / 96;49253 -1 var isSmallFont = bold && ptSize < boldTextPt || !bold && ptSize < largeTextPt;49254 -1 var _ref48 = isSmallFont ? contrastRatio.normal : contrastRatio.large, expected = _ref48.expected, minThreshold = _ref48.minThreshold, maxThreshold = _ref48.maxThreshold;49255 -1 var isValid = contrast > expected;49256 -1 var nodeToCheck = node;49257 -1 while (nodeToCheck) {49258 -1 if (hasPsuedoElement(nodeToCheck, ':before') || hasPsuedoElement(nodeToCheck, ':after')) {49259 -1 this.data({49260 -1 messageKey: 'pseudoContent'49261 -1 });49262 -1 this.relatedNodes(nodeToCheck);49263 -1 return void 0;-1 23981 var hasDt = false, hasDd = false, nodeName2; -1 23982 for (var i = 0; i < children.length; i++) { -1 23983 nodeName2 = children[i].props.nodeName.toUpperCase(); -1 23984 if (nodeName2 === 'DT') { -1 23985 hasDt = true; -1 23986 } -1 23987 if (hasDt && nodeName2 === 'DD') { -1 23988 return false; -1 23989 } -1 23990 if (nodeName2 === 'DD') { -1 23991 hasDd = true; 49264 23992 }49265 -1 nodeToCheck = nodeToCheck.parentElement;49266 23993 }49267 -1 if (typeof minThreshold === 'number' && contrast < minThreshold || typeof maxThreshold === 'number' && contrast > maxThreshold) {-1 23994 return hasDt || hasDd; -1 23995 } -1 23996 var structured_dlitems_evaluate_default = structuredDlitemsEvaluate; -1 23997 function captionEvaluate(node, options, virtualNode) { -1 23998 var tracks = query_selector_all_default(virtualNode, 'track'); -1 23999 var hasCaptions = tracks.some(function(vNode) { -1 24000 return (vNode.attr('kind') || '').toLowerCase() === 'captions'; -1 24001 }); -1 24002 return hasCaptions ? false : void 0; -1 24003 } -1 24004 var caption_evaluate_default = captionEvaluate; -1 24005 var joinStr = ' > '; -1 24006 function frameTestedAfter(results) { -1 24007 var iframes = {}; -1 24008 return results.filter(function(result) { -1 24009 var frameResult = result.node.ancestry[result.node.ancestry.length - 1] !== 'html'; -1 24010 if (frameResult) { -1 24011 var ancestry2 = result.node.ancestry.flat(Infinity).join(joinStr); -1 24012 iframes[ancestry2] = result; -1 24013 return true; -1 24014 } -1 24015 var ancestry = result.node.ancestry.slice(0, result.node.ancestry.length - 1).flat(Infinity).join(joinStr); -1 24016 if (iframes[ancestry]) { -1 24017 iframes[ancestry].result = true; -1 24018 } -1 24019 return false; -1 24020 }); -1 24021 } -1 24022 var frame_tested_after_default = frameTestedAfter; -1 24023 function frameTestedEvaluate(node, options) { -1 24024 return options.isViolation ? false : void 0; -1 24025 } -1 24026 var frame_tested_evaluate_default = frameTestedEvaluate; -1 24027 function noAutoplayAudioEvaluate(node, options) { -1 24028 if (!node.duration) { -1 24029 console.warn('axe.utils.preloadMedia did not load metadata'); -1 24030 return void 0; -1 24031 } -1 24032 var _options$allowedDurat = options.allowedDuration, allowedDuration = _options$allowedDurat === void 0 ? 3 : _options$allowedDurat; -1 24033 var playableDuration = getPlayableDuration(node); -1 24034 if (playableDuration <= allowedDuration && !node.hasAttribute('loop')) { 49268 24035 return true; 49269 24036 }49270 -1 var truncatedResult = Math.floor(contrast * 100) / 100;49271 -1 var missing;49272 -1 if (bgColor === null) {49273 -1 missing = incomplete_data_default.get('bgColor');-1 24037 if (!node.hasAttribute('controls')) { -1 24038 return false; 49274 24039 }49275 -1 var equalRatio = truncatedResult === 1;49276 -1 var shortTextContent = visibleText.length === 1;49277 -1 if (equalRatio) {49278 -1 missing = incomplete_data_default.set('bgColor', 'equalRatio');49279 -1 } else if (shortTextContent && !ignoreLength) {49280 -1 missing = 'shortTextContent';-1 24040 return true; -1 24041 function getPlayableDuration(elm) { -1 24042 if (!elm.currentSrc) { -1 24043 return 0; -1 24044 } -1 24045 var playbackRange = getPlaybackRange(elm.currentSrc); -1 24046 if (!playbackRange) { -1 24047 return Math.abs(elm.duration - (elm.currentTime || 0)); -1 24048 } -1 24049 if (playbackRange.length === 1) { -1 24050 return Math.abs(elm.duration - playbackRange[0]); -1 24051 } -1 24052 return Math.abs(playbackRange[1] - playbackRange[0]); 49281 24053 }49282 -1 var data2 = {49283 -1 fgColor: fgColor ? fgColor.toHexString() : void 0,49284 -1 bgColor: bgColor ? bgColor.toHexString() : void 0,49285 -1 contrastRatio: truncatedResult,49286 -1 fontSize: ''.concat((fontSize * 72 / 96).toFixed(1), 'pt (').concat(fontSize, 'px)'),49287 -1 fontWeight: bold ? 'bold' : 'normal',49288 -1 messageKey: missing,49289 -1 expectedContrastRatio: expected + ':1'49290 -1 };49291 -1 this.data(data2);49292 -1 if (fgColor === null || bgColor === null || equalRatio || shortTextContent && !ignoreLength && !isValid) {49293 -1 missing = null;49294 -1 incomplete_data_default.clear();49295 -1 this.relatedNodes(bgNodes);49296 -1 return void 0;-1 24054 function getPlaybackRange(src) { -1 24055 var match = src.match(/#t=(.*)/); -1 24056 if (!match) { -1 24057 return; -1 24058 } -1 24059 var _match = _slicedToArray(match, 2), value = _match[1]; -1 24060 var ranges = value.split(','); -1 24061 return ranges.map(function(range) { -1 24062 if (/:/.test(range)) { -1 24063 return convertHourMinSecToSeconds(range); -1 24064 } -1 24065 return parseFloat(range); -1 24066 }); 49297 24067 }49298 -1 if (!isValid) {49299 -1 this.relatedNodes(bgNodes);-1 24068 function convertHourMinSecToSeconds(hhMmSs) { -1 24069 var parts = hhMmSs.split(':'); -1 24070 var secs = 0; -1 24071 var mins = 1; -1 24072 while (parts.length > 0) { -1 24073 secs += mins * parseInt(parts.pop(), 10); -1 24074 mins *= 60; -1 24075 } -1 24076 return parseFloat(secs); 49300 24077 }49301 -1 return isValid;49302 -1 }49303 -1 var color_contrast_evaluate_default = colorContrastEvaluate;49304 -1 function getContrast2(color1, color22) {49305 -1 var c1lum = color1.getRelativeLuminance();49306 -1 var c2lum = color22.getRelativeLuminance();49307 -1 return (Math.max(c1lum, c2lum) + .05) / (Math.min(c1lum, c2lum) + .05);49308 -1 }49309 -1 var blockLike2 = [ 'block', 'list-item', 'table', 'flex', 'grid', 'inline-block' ];49310 -1 function isBlock2(elm) {49311 -1 var display = window.getComputedStyle(elm).getPropertyValue('display');49312 -1 return blockLike2.indexOf(display) !== -1 || display.substr(0, 6) === 'table-';49313 24078 }49314 -1 function linkInTextBlockEvaluate(node) {49315 -1 if (isBlock2(node)) {49316 -1 return false;49317 -1 }49318 -1 var parentBlock = get_composed_parent_default(node);49319 -1 while (parentBlock.nodeType === 1 && !isBlock2(parentBlock)) {49320 -1 parentBlock = get_composed_parent_default(parentBlock);-1 24079 var no_autoplay_audio_evaluate_default = noAutoplayAudioEvaluate; -1 24080 function cssOrientationLockEvaluate(node, options, virtualNode, context5) { -1 24081 var _ref66 = context5 || {}, _ref66$cssom = _ref66.cssom, cssom = _ref66$cssom === void 0 ? void 0 : _ref66$cssom; -1 24082 var _ref67 = options || {}, _ref67$degreeThreshol = _ref67.degreeThreshold, degreeThreshold = _ref67$degreeThreshol === void 0 ? 0 : _ref67$degreeThreshol; -1 24083 if (!cssom || !cssom.length) { -1 24084 return void 0; 49321 24085 }49322 -1 this.relatedNodes([ parentBlock ]);49323 -1 if (element_is_distinct_default(node, parentBlock)) {49324 -1 return true;49325 -1 } else {49326 -1 var nodeColor, parentColor;49327 -1 nodeColor = get_foreground_color_default(node);49328 -1 parentColor = get_foreground_color_default(parentBlock);49329 -1 if (!nodeColor || !parentColor) {49330 -1 return void 0;49331 -1 }49332 -1 var contrast = getContrast2(nodeColor, parentColor);49333 -1 if (contrast === 1) {49334 -1 return true;49335 -1 } else if (contrast >= 3) {49336 -1 incomplete_data_default.set('fgColor', 'bgContrast');49337 -1 this.data({49338 -1 messageKey: incomplete_data_default.get('fgColor')49339 -1 });49340 -1 incomplete_data_default.clear();49341 -1 return void 0;-1 24086 var isLocked = false; -1 24087 var relatedElements = []; -1 24088 var rulesGroupByDocumentFragment = groupCssomByDocument(cssom); -1 24089 var _loop5 = function _loop5() { -1 24090 var key = _Object$keys2[_i21]; -1 24091 var _rulesGroupByDocument = rulesGroupByDocumentFragment[key], root = _rulesGroupByDocument.root, rules = _rulesGroupByDocument.rules; -1 24092 var orientationRules = rules.filter(isMediaRuleWithOrientation); -1 24093 if (!orientationRules.length) { -1 24094 return 'continue'; 49342 24095 }49343 -1 nodeColor = get_background_color_default(node);49344 -1 parentColor = get_background_color_default(parentBlock);49345 -1 if (!nodeColor || !parentColor || getContrast2(nodeColor, parentColor) >= 3) {49346 -1 var reason;49347 -1 if (!nodeColor || !parentColor) {49348 -1 reason = incomplete_data_default.get('bgColor');49349 -1 } else {49350 -1 reason = 'bgContrast';49351 -1 }49352 -1 incomplete_data_default.set('fgColor', reason);49353 -1 this.data({49354 -1 messageKey: incomplete_data_default.get('fgColor')-1 24096 orientationRules.forEach(function(_ref68) { -1 24097 var cssRules = _ref68.cssRules; -1 24098 Array.from(cssRules).forEach(function(cssRule) { -1 24099 var locked = getIsOrientationLocked(cssRule); -1 24100 if (locked && cssRule.selectorText.toUpperCase() !== 'HTML') { -1 24101 var elms = Array.from(root.querySelectorAll(cssRule.selectorText)) || []; -1 24102 relatedElements = relatedElements.concat(elms); -1 24103 } -1 24104 isLocked = isLocked || locked; 49355 24105 });49356 -1 incomplete_data_default.clear();49357 -1 return void 0;-1 24106 }); -1 24107 }; -1 24108 for (var _i21 = 0, _Object$keys2 = Object.keys(rulesGroupByDocumentFragment); _i21 < _Object$keys2.length; _i21++) { -1 24109 var _ret2 = _loop5(); -1 24110 if (_ret2 === 'continue') { -1 24111 continue; 49358 24112 } 49359 24113 }49360 -1 return false;49361 -1 }49362 -1 var link_in_text_block_evaluate_default = linkInTextBlockEvaluate;49363 -1 function autocompleteAppropriateEvaluate(node, options, virtualNode) {49364 -1 if (virtualNode.props.nodeName !== 'input') {-1 24114 if (!isLocked) { 49365 24115 return true; 49366 24116 }49367 -1 var number = [ 'text', 'search', 'number', 'tel' ];49368 -1 var url = [ 'text', 'search', 'url' ];49369 -1 var allowedTypesMap = {49370 -1 bday: [ 'text', 'search', 'date' ],49371 -1 email: [ 'text', 'search', 'email' ],49372 -1 username: [ 'text', 'search', 'email' ],49373 -1 'street-address': [ 'text' ],49374 -1 tel: [ 'text', 'search', 'tel' ],49375 -1 'tel-country-code': [ 'text', 'search', 'tel' ],49376 -1 'tel-national': [ 'text', 'search', 'tel' ],49377 -1 'tel-area-code': [ 'text', 'search', 'tel' ],49378 -1 'tel-local': [ 'text', 'search', 'tel' ],49379 -1 'tel-local-prefix': [ 'text', 'search', 'tel' ],49380 -1 'tel-local-suffix': [ 'text', 'search', 'tel' ],49381 -1 'tel-extension': [ 'text', 'search', 'tel' ],49382 -1 'cc-number': number,49383 -1 'cc-exp': [ 'text', 'search', 'month', 'tel' ],49384 -1 'cc-exp-month': number,49385 -1 'cc-exp-year': number,49386 -1 'cc-csc': number,49387 -1 'transaction-amount': number,49388 -1 'bday-day': number,49389 -1 'bday-month': number,49390 -1 'bday-year': number,49391 -1 'new-password': [ 'text', 'search', 'password' ],49392 -1 'current-password': [ 'text', 'search', 'password' ],49393 -1 url: url,49394 -1 photo: url,49395 -1 impp: url49396 -1 };49397 -1 if (_typeof(options) === 'object') {49398 -1 Object.keys(options).forEach(function(key) {49399 -1 if (!allowedTypesMap[key]) {49400 -1 allowedTypesMap[key] = [];-1 24117 if (relatedElements.length) { -1 24118 this.relatedNodes(relatedElements); -1 24119 } -1 24120 return false; -1 24121 function groupCssomByDocument(cssObjectModel) { -1 24122 return cssObjectModel.reduce(function(out, _ref69) { -1 24123 var sheet = _ref69.sheet, root = _ref69.root, shadowId = _ref69.shadowId; -1 24124 var key = shadowId ? shadowId : 'topDocument'; -1 24125 if (!out[key]) { -1 24126 out[key] = { -1 24127 root: root, -1 24128 rules: [] -1 24129 }; 49401 24130 }49402 -1 allowedTypesMap[key] = allowedTypesMap[key].concat(options[key]);49403 -1 });-1 24131 if (!sheet || !sheet.cssRules) { -1 24132 return out; -1 24133 } -1 24134 var rules = Array.from(sheet.cssRules); -1 24135 out[key].rules = out[key].rules.concat(rules); -1 24136 return out; -1 24137 }, {}); -1 24138 } -1 24139 function isMediaRuleWithOrientation(_ref70) { -1 24140 var type = _ref70.type, cssText = _ref70.cssText; -1 24141 if (type !== 4) { -1 24142 return false; -1 24143 } -1 24144 return /orientation:\s*landscape/i.test(cssText) || /orientation:\s*portrait/i.test(cssText); -1 24145 } -1 24146 function getIsOrientationLocked(_ref71) { -1 24147 var selectorText = _ref71.selectorText, style = _ref71.style; -1 24148 if (!selectorText || style.length <= 0) { -1 24149 return false; -1 24150 } -1 24151 var transformStyle = style.transform || style.webkitTransform || style.msTransform || false; -1 24152 if (!transformStyle) { -1 24153 return false; -1 24154 } -1 24155 var matches14 = transformStyle.match(/(rotate|rotateZ|rotate3d|matrix|matrix3d)\(([^)]+)\)(?!.*(rotate|rotateZ|rotate3d|matrix|matrix3d))/); -1 24156 if (!matches14) { -1 24157 return false; -1 24158 } -1 24159 var _matches = _slicedToArray(matches14, 3), transformFn = _matches[1], transformFnValue = _matches[2]; -1 24160 var degrees = getRotationInDegrees(transformFn, transformFnValue); -1 24161 if (!degrees) { -1 24162 return false; -1 24163 } -1 24164 degrees = Math.abs(degrees); -1 24165 if (Math.abs(degrees - 180) % 180 <= degreeThreshold) { -1 24166 return false; -1 24167 } -1 24168 return Math.abs(degrees - 90) % 90 <= degreeThreshold; 49404 24169 }49405 -1 var autocompleteAttr = virtualNode.attr('autocomplete');49406 -1 var autocompleteTerms = autocompleteAttr.split(/\s+/g).map(function(term) {49407 -1 return term.toLowerCase();49408 -1 });49409 -1 var purposeTerm = autocompleteTerms[autocompleteTerms.length - 1];49410 -1 if (_autocomplete.stateTerms.includes(purposeTerm)) {49411 -1 return true;-1 24170 function getRotationInDegrees(transformFunction, transformFnValue) { -1 24171 switch (transformFunction) { -1 24172 case 'rotate': -1 24173 case 'rotateZ': -1 24174 return getAngleInDegrees(transformFnValue); -1 24175 -1 24176 case 'rotate3d': -1 24177 var _transformFnValue$spl = transformFnValue.split(',').map(function(value) { -1 24178 return value.trim(); -1 24179 }), _transformFnValue$spl2 = _slicedToArray(_transformFnValue$spl, 4), z = _transformFnValue$spl2[2], angleWithUnit = _transformFnValue$spl2[3]; -1 24180 if (parseInt(z) === 0) { -1 24181 return; -1 24182 } -1 24183 return getAngleInDegrees(angleWithUnit); -1 24184 -1 24185 case 'matrix': -1 24186 case 'matrix3d': -1 24187 return getAngleInDegreesFromMatrixTransform(transformFnValue); -1 24188 -1 24189 default: -1 24190 return; -1 24191 } 49412 24192 }49413 -1 var allowedTypes = allowedTypesMap[purposeTerm];49414 -1 var type = virtualNode.hasAttr('type') ? sanitize_default(virtualNode.attr('type')).toLowerCase() : 'text';49415 -1 type = valid_input_type_default().includes(type) ? type : 'text';49416 -1 if (typeof allowedTypes === 'undefined') {49417 -1 return type === 'text';-1 24193 function getAngleInDegrees(angleWithUnit) { -1 24194 var _ref72 = angleWithUnit.match(/(deg|grad|rad|turn)/) || [], _ref73 = _slicedToArray(_ref72, 1), unit = _ref73[0]; -1 24195 if (!unit) { -1 24196 return; -1 24197 } -1 24198 var angle = parseFloat(angleWithUnit.replace(unit, '')); -1 24199 switch (unit) { -1 24200 case 'rad': -1 24201 return convertRadToDeg(angle); -1 24202 -1 24203 case 'grad': -1 24204 return convertGradToDeg(angle); -1 24205 -1 24206 case 'turn': -1 24207 return convertTurnToDeg(angle); -1 24208 -1 24209 case 'deg': -1 24210 default: -1 24211 return parseInt(angle); -1 24212 } 49418 24213 }49419 -1 return allowedTypes.includes(type);49420 -1 }49421 -1 var autocomplete_appropriate_evaluate_default = autocompleteAppropriateEvaluate;49422 -1 function autocompleteValidEvaluate(node, options, virtualNode) {49423 -1 var autocomplete2 = virtualNode.attr('autocomplete') || '';49424 -1 return is_valid_autocomplete_default(autocomplete2, options);49425 -1 }49426 -1 var autocomplete_valid_evaluate_default = autocompleteValidEvaluate;49427 -1 function attrNonSpaceContentEvaluate(node) {49428 -1 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};49429 -1 var vNode = arguments.length > 2 ? arguments[2] : undefined;49430 -1 if (!options.attribute || typeof options.attribute !== 'string') {49431 -1 throw new TypeError('attr-non-space-content requires options.attribute to be a string');-1 24214 function getAngleInDegreesFromMatrixTransform(transformFnValue) { -1 24215 var values = transformFnValue.split(','); -1 24216 if (values.length <= 6) { -1 24217 var _values = _slicedToArray(values, 2), a = _values[0], b2 = _values[1]; -1 24218 var radians = Math.atan2(parseFloat(b2), parseFloat(a)); -1 24219 return convertRadToDeg(radians); -1 24220 } -1 24221 var sinB = parseFloat(values[8]); -1 24222 var b = Math.asin(sinB); -1 24223 var cosB = Math.cos(b); -1 24224 var rotateZRadians = Math.acos(parseFloat(values[0]) / cosB); -1 24225 return convertRadToDeg(rotateZRadians); 49432 24226 }49433 -1 if (!vNode.hasAttr(options.attribute)) {49434 -1 this.data({49435 -1 messageKey: 'noAttr'49436 -1 });49437 -1 return false;-1 24227 function convertRadToDeg(radians) { -1 24228 return Math.round(radians * (180 / Math.PI)); 49438 24229 }49439 -1 var attribute = vNode.attr(options.attribute);49440 -1 var attributeIsEmpty = !sanitize_default(attribute);49441 -1 if (attributeIsEmpty) {49442 -1 this.data({49443 -1 messageKey: 'emptyAttr'49444 -1 });49445 -1 return false;-1 24230 function convertGradToDeg(grad) { -1 24231 grad = grad % 400; -1 24232 if (grad < 0) { -1 24233 grad += 400; -1 24234 } -1 24235 return Math.round(grad / 400 * 360); 49446 24236 }49447 -1 return true;49448 -1 }49449 -1 var attr_non_space_content_evaluate_default = attrNonSpaceContentEvaluate;49450 -1 function pageHasElmAfter(results) {49451 -1 var elmUsedAnywhere = results.some(function(frameResult) {49452 -1 return frameResult.result === true;49453 -1 });49454 -1 if (elmUsedAnywhere) {49455 -1 results.forEach(function(result) {49456 -1 result.result = true;49457 -1 });-1 24237 function convertTurnToDeg(turn) { -1 24238 return Math.round(360 / (1 / turn)); 49458 24239 }49459 -1 return results;49460 24240 }49461 -1 var has_descendant_after_default = pageHasElmAfter;49462 -1 function hasDescendant(node, options, virtualNode) {49463 -1 if (!options || !options.selector || typeof options.selector !== 'string') {49464 -1 throw new TypeError('has-descendant requires options.selector to be a string');-1 24241 var css_orientation_lock_evaluate_default = cssOrientationLockEvaluate; -1 24242 function metaViewportScaleEvaluate(node, options, virtualNode) { -1 24243 var _ref74 = options || {}, _ref74$scaleMinimum = _ref74.scaleMinimum, scaleMinimum = _ref74$scaleMinimum === void 0 ? 2 : _ref74$scaleMinimum, _ref74$lowerBound = _ref74.lowerBound, lowerBound = _ref74$lowerBound === void 0 ? false : _ref74$lowerBound; -1 24244 var content = virtualNode.attr('content') || ''; -1 24245 if (!content) { -1 24246 return true; 49465 24247 }49466 -1 var matchingElms = query_selector_all_filter_default(virtualNode, options.selector, function(vNode) {49467 -1 return is_visible_default(vNode.actualNode, true);49468 -1 });49469 -1 this.relatedNodes(matchingElms.map(function(vNode) {49470 -1 return vNode.actualNode;49471 -1 }));49472 -1 return matchingElms.length > 0;49473 -1 }49474 -1 var has_descendant_evaluate_default = hasDescendant;49475 -1 function hasTextContentEvaluate(node, options, virtualNode) {49476 -1 try {49477 -1 return sanitize_default(subtree_text_default(virtualNode)) !== '';49478 -1 } catch (e) {49479 -1 return void 0;-1 24248 var result = content.split(/[;,]/).reduce(function(out, item) { -1 24249 var contentValue = item.trim(); -1 24250 if (!contentValue) { -1 24251 return out; -1 24252 } -1 24253 var _contentValue$split = contentValue.split('='), _contentValue$split2 = _slicedToArray(_contentValue$split, 2), key = _contentValue$split2[0], value = _contentValue$split2[1]; -1 24254 if (!key || !value) { -1 24255 return out; -1 24256 } -1 24257 var curatedKey = key.toLowerCase().trim(); -1 24258 var curatedValue = value.toLowerCase().trim(); -1 24259 if (curatedKey === 'maximum-scale' && curatedValue === 'yes') { -1 24260 curatedValue = 1; -1 24261 } -1 24262 if (curatedKey === 'maximum-scale' && parseFloat(curatedValue) < 0) { -1 24263 return out; -1 24264 } -1 24265 out[curatedKey] = curatedValue; -1 24266 return out; -1 24267 }, {}); -1 24268 if (lowerBound && result['maximum-scale'] && parseFloat(result['maximum-scale']) < lowerBound) { -1 24269 return true; 49480 24270 }49481 -1 }49482 -1 var has_text_content_evaluate_default = hasTextContentEvaluate;49483 -1 function matchesDefinitionEvaluate(_, options, virtualNode) {49484 -1 return matches_default3(virtualNode, options.matcher);49485 -1 }49486 -1 var matches_definition_evaluate_default = matchesDefinitionEvaluate;49487 -1 function pageNoDuplicateAfter(results) {49488 -1 return results.filter(function(checkResult) {49489 -1 return checkResult.data !== 'ignored';49490 -1 });49491 -1 }49492 -1 var page_no_duplicate_after_default = pageNoDuplicateAfter;49493 -1 function pageNoDuplicateEvaluate(node, options, virtualNode) {49494 -1 if (!options || !options.selector || typeof options.selector !== 'string') {49495 -1 throw new TypeError('page-no-duplicate requires options.selector to be a string');-1 24271 if (!lowerBound && result['user-scalable'] === 'no') { -1 24272 this.data('user-scalable=no'); -1 24273 return false; 49496 24274 }49497 -1 var key = 'page-no-duplicate;' + options.selector;49498 -1 if (cache_default.get(key)) {49499 -1 this.data('ignored');49500 -1 return;-1 24275 var userScalableAsFloat = parseFloat(result['user-scalable']); -1 24276 if (!lowerBound && result['user-scalable'] && (userScalableAsFloat || userScalableAsFloat === 0) && userScalableAsFloat > -1 && userScalableAsFloat < 1) { -1 24277 this.data('user-scalable'); -1 24278 return false; 49501 24279 }49502 -1 cache_default.set(key, true);49503 -1 var elms = query_selector_all_filter_default(axe._tree[0], options.selector, function(elm) {49504 -1 return is_visible_default(elm.actualNode);49505 -1 });49506 -1 if (typeof options.nativeScopeFilter === 'string') {49507 -1 elms = elms.filter(function(elm) {49508 -1 return elm.actualNode.hasAttribute('role') || !find_up_virtual_default(elm, options.nativeScopeFilter);49509 -1 });-1 24280 if (result['maximum-scale'] && parseFloat(result['maximum-scale']) < scaleMinimum) { -1 24281 this.data('maximum-scale'); -1 24282 return false; 49510 24283 }49511 -1 this.relatedNodes(elms.filter(function(elm) {49512 -1 return elm !== virtualNode;49513 -1 }).map(function(elm) {49514 -1 return elm.actualNode;49515 -1 }));49516 -1 return elms.length <= 1;-1 24284 return true; 49517 24285 }49518 -1 var page_no_duplicate_evaluate_default = pageNoDuplicateEvaluate;-1 24286 var meta_viewport_scale_evaluate_default = metaViewportScaleEvaluate; 49519 24287 function headingOrderAfter(results) { 49520 24288 var headingOrder = getHeadingOrder(results); 49521 24289 results.forEach(function(result) { @@ -49538,14 +24306,14 @@ module.exports = { 49538 24306 } 49539 24307 function getHeadingOrder(results) { 49540 24308 results = _toConsumableArray(results);49541 -1 results.sort(function(_ref49, _ref50) {49542 -1 var nodeA = _ref49.node;49543 -1 var nodeB = _ref50.node;-1 24309 results.sort(function(_ref75, _ref76) { -1 24310 var nodeA = _ref75.node; -1 24311 var nodeB = _ref76.node; 49544 24312 return nodeA.ancestry.length - nodeB.ancestry.length; 49545 24313 }); 49546 24314 var headingOrder = results.reduce(mergeHeadingOrder, []);49547 -1 return headingOrder.filter(function(_ref51) {49548 -1 var level = _ref51.level;-1 24315 return headingOrder.filter(function(_ref77) { -1 24316 var level = _ref77.level; 49549 24317 return level !== -1; 49550 24318 }); 49551 24319 } @@ -49579,7 +24347,7 @@ module.exports = { 49579 24347 } 49580 24348 function findHeadingOrderIndex(headingOrder, ancestry) { 49581 24349 return headingOrder.findIndex(function(heading) {49582 -1 return matchAncestry(heading.ancestry, ancestry);-1 24350 return match_ancestry_default(heading.ancestry, ancestry); 49583 24351 }); 49584 24352 } 49585 24353 function addFrameToHeadingAncestry(heading, frameAncestry) { @@ -49588,39 +24356,29 @@ module.exports = { 49588 24356 ancestry: ancestry 49589 24357 }); 49590 24358 }49591 -1 function matchAncestry(ancestryA, ancestryB) {49592 -1 if (ancestryA.length !== ancestryB.length) {49593 -1 return false;49594 -1 }49595 -1 return ancestryA.every(function(selectorA, index) {49596 -1 var selectorB = ancestryB[index];49597 -1 if (!Array.isArray(selectorA)) {49598 -1 return selectorA === selectorB;49599 -1 }49600 -1 if (selectorA.length !== selectorB.length) {49601 -1 return false;49602 -1 }49603 -1 return selectorA.every(function(str, index2) {49604 -1 return selectorB[index2] === str;49605 -1 });49606 -1 });49607 -1 }49608 24359 function shortenArray(arr, spliceLength) { 49609 24360 return arr.slice(0, arr.length - spliceLength); 49610 24361 } 49611 24362 function getLevel(vNode) {49612 -1 var role = vNode.attr('role');49613 -1 if (role && role.includes('heading')) {49614 -1 var ariaHeadingLevel = vNode.attr('aria-level');49615 -1 var level = parseInt(ariaHeadingLevel, 10);49616 -1 if (isNaN(level) || level < 1 || level > 6) {49617 -1 return 2;-1 24363 var role = get_role_default(vNode); -1 24364 var headingRole = role && role.includes('heading'); -1 24365 var ariaHeadingLevel = vNode.attr('aria-level'); -1 24366 var ariaLevel = parseInt(ariaHeadingLevel, 10); -1 24367 var _ref78 = vNode.props.nodeName.match(/h(\d)/) || [], _ref79 = _slicedToArray(_ref78, 2), headingLevel = _ref79[1]; -1 24368 if (!headingRole) { -1 24369 return -1; -1 24370 } -1 24371 if (headingLevel && !ariaHeadingLevel) { -1 24372 return parseInt(headingLevel, 10); -1 24373 } -1 24374 if (isNaN(ariaLevel) || ariaLevel < 1) { -1 24375 if (headingLevel) { -1 24376 return parseInt(headingLevel, 10); 49618 24377 }49619 -1 return level;-1 24378 return 2; 49620 24379 }49621 -1 var headingLevel = vNode.props.nodeName.match(/h(\d)/);49622 -1 if (headingLevel) {49623 -1 return parseInt(headingLevel[1], 10);-1 24380 if (ariaLevel) { -1 24381 return ariaLevel; 49624 24382 } 49625 24383 return -1; 49626 24384 } @@ -49672,25 +24430,25 @@ module.exports = { 49672 24430 if (results.length < 2) { 49673 24431 return results; 49674 24432 }49675 -1 var incompleteResults = results.filter(function(_ref52) {49676 -1 var result = _ref52.result;-1 24433 var incompleteResults = results.filter(function(_ref80) { -1 24434 var result = _ref80.result; 49677 24435 return result !== void 0; 49678 24436 }); 49679 24437 var uniqueResults = []; 49680 24438 var nameMap = {};49681 -1 var _loop5 = function _loop5(index) {-1 24439 var _loop6 = function _loop6(index) { 49682 24440 var _currentResult$relate; 49683 24441 var currentResult = incompleteResults[index]; 49684 24442 var _currentResult$data = currentResult.data, name = _currentResult$data.name, urlProps = _currentResult$data.urlProps; 49685 24443 if (nameMap[name]) { 49686 24444 return 'continue'; 49687 24445 }49688 -1 var sameNameResults = incompleteResults.filter(function(_ref53, resultNum) {49689 -1 var data2 = _ref53.data;-1 24446 var sameNameResults = incompleteResults.filter(function(_ref81, resultNum) { -1 24447 var data2 = _ref81.data; 49690 24448 return data2.name === name && resultNum !== index; 49691 24449 });49692 -1 var isSameUrl = sameNameResults.every(function(_ref54) {49693 -1 var data2 = _ref54.data;-1 24450 var isSameUrl = sameNameResults.every(function(_ref82) { -1 24451 var data2 = _ref82.data; 49694 24452 return isIdenticalObject(data2.urlProps, urlProps); 49695 24453 }); 49696 24454 if (sameNameResults.length && !isSameUrl) { @@ -49704,89 +24462,379 @@ module.exports = { 49704 24462 uniqueResults.push(currentResult); 49705 24463 }; 49706 24464 for (var index = 0; index < incompleteResults.length; index++) {49707 -1 var _ret2 = _loop5(index);49708 -1 if (_ret2 === 'continue') {-1 24465 var _ret3 = _loop6(index); -1 24466 if (_ret3 === 'continue') { 49709 24467 continue; 49710 24468 } 49711 24469 }49712 -1 return uniqueResults;-1 24470 return uniqueResults; -1 24471 } -1 24472 var identical_links_same_purpose_after_default = identicalLinksSamePurposeAfter; -1 24473 var commons_exports = {}; -1 24474 __export(commons_exports, { -1 24475 aria: function aria() { -1 24476 return aria_exports; -1 24477 }, -1 24478 color: function color() { -1 24479 return color_exports; -1 24480 }, -1 24481 dom: function dom() { -1 24482 return dom_exports; -1 24483 }, -1 24484 forms: function forms() { -1 24485 return forms_exports; -1 24486 }, -1 24487 matches: function matches() { -1 24488 return matches_default3; -1 24489 }, -1 24490 standards: function standards() { -1 24491 return standards_exports; -1 24492 }, -1 24493 table: function table() { -1 24494 return table_exports; -1 24495 }, -1 24496 text: function text() { -1 24497 return text_exports; -1 24498 }, -1 24499 utils: function utils() { -1 24500 return utils_exports; -1 24501 } -1 24502 }); -1 24503 var forms_exports = {}; -1 24504 __export(forms_exports, { -1 24505 isAriaCombobox: function isAriaCombobox() { -1 24506 return is_aria_combobox_default; -1 24507 }, -1 24508 isAriaListbox: function isAriaListbox() { -1 24509 return is_aria_listbox_default; -1 24510 }, -1 24511 isAriaRange: function isAriaRange() { -1 24512 return is_aria_range_default; -1 24513 }, -1 24514 isAriaTextbox: function isAriaTextbox() { -1 24515 return is_aria_textbox_default; -1 24516 }, -1 24517 isDisabled: function isDisabled() { -1 24518 return is_disabled_default; -1 24519 }, -1 24520 isNativeSelect: function isNativeSelect() { -1 24521 return is_native_select_default; -1 24522 }, -1 24523 isNativeTextbox: function isNativeTextbox() { -1 24524 return is_native_textbox_default; -1 24525 } -1 24526 }); -1 24527 var disabledNodeNames = [ 'fieldset', 'button', 'select', 'input', 'textarea' ]; -1 24528 function isDisabled(virtualNode) { -1 24529 var disabledState = virtualNode._isDisabled; -1 24530 if (typeof disabledState === 'boolean') { -1 24531 return disabledState; -1 24532 } -1 24533 var nodeName2 = virtualNode.props.nodeName; -1 24534 var ariaDisabled = virtualNode.attr('aria-disabled'); -1 24535 if (disabledNodeNames.includes(nodeName2) && virtualNode.hasAttr('disabled')) { -1 24536 disabledState = true; -1 24537 } else if (ariaDisabled) { -1 24538 disabledState = ariaDisabled.toLowerCase() === 'true'; -1 24539 } else if (virtualNode.parent) { -1 24540 disabledState = isDisabled(virtualNode.parent); -1 24541 } else { -1 24542 disabledState = false; -1 24543 } -1 24544 virtualNode._isDisabled = disabledState; -1 24545 return disabledState; -1 24546 } -1 24547 var is_disabled_default = isDisabled; -1 24548 var table_exports = {}; -1 24549 __export(table_exports, { -1 24550 getAllCells: function getAllCells() { -1 24551 return get_all_cells_default; -1 24552 }, -1 24553 getCellPosition: function getCellPosition() { -1 24554 return get_cell_position_default; -1 24555 }, -1 24556 getHeaders: function getHeaders() { -1 24557 return get_headers_default; -1 24558 }, -1 24559 getScope: function getScope() { -1 24560 return get_scope_default; -1 24561 }, -1 24562 isColumnHeader: function isColumnHeader() { -1 24563 return is_column_header_default; -1 24564 }, -1 24565 isDataCell: function isDataCell() { -1 24566 return is_data_cell_default; -1 24567 }, -1 24568 isDataTable: function isDataTable() { -1 24569 return is_data_table_default; -1 24570 }, -1 24571 isHeader: function isHeader() { -1 24572 return is_header_default; -1 24573 }, -1 24574 isRowHeader: function isRowHeader() { -1 24575 return is_row_header_default; -1 24576 }, -1 24577 toArray: function toArray() { -1 24578 return to_grid_default; -1 24579 }, -1 24580 toGrid: function toGrid() { -1 24581 return to_grid_default; -1 24582 }, -1 24583 traverse: function traverse() { -1 24584 return traverse_default; -1 24585 } -1 24586 }); -1 24587 function getAllCells(tableElm) { -1 24588 var rowIndex, cellIndex, rowLength, cellLength; -1 24589 var cells = []; -1 24590 for (rowIndex = 0, rowLength = tableElm.rows.length; rowIndex < rowLength; rowIndex++) { -1 24591 for (cellIndex = 0, cellLength = tableElm.rows[rowIndex].cells.length; cellIndex < cellLength; cellIndex++) { -1 24592 cells.push(tableElm.rows[rowIndex].cells[cellIndex]); -1 24593 } -1 24594 } -1 24595 return cells; -1 24596 } -1 24597 var get_all_cells_default = getAllCells; -1 24598 function traverseForHeaders(headerType, position, tableGrid) { -1 24599 var property = headerType === 'row' ? '_rowHeaders' : '_colHeaders'; -1 24600 var predicate = headerType === 'row' ? is_row_header_default : is_column_header_default; -1 24601 var startCell = tableGrid[position.y][position.x]; -1 24602 var colspan = startCell.colSpan - 1; -1 24603 var rowspanAttr = startCell.getAttribute('rowspan'); -1 24604 var rowspanValue = parseInt(rowspanAttr) === 0 || startCell.rowspan === 0 ? tableGrid.length : startCell.rowSpan; -1 24605 var rowspan = rowspanValue - 1; -1 24606 var rowStart = position.y + rowspan; -1 24607 var colStart = position.x + colspan; -1 24608 var rowEnd = headerType === 'row' ? position.y : 0; -1 24609 var colEnd = headerType === 'row' ? 0 : position.x; -1 24610 var headers; -1 24611 var cells = []; -1 24612 for (var row = rowStart; row >= rowEnd && !headers; row--) { -1 24613 for (var col = colStart; col >= colEnd; col--) { -1 24614 var cell = tableGrid[row] ? tableGrid[row][col] : void 0; -1 24615 if (!cell) { -1 24616 continue; -1 24617 } -1 24618 var vNode = axe.utils.getNodeFromTree(cell); -1 24619 if (vNode[property]) { -1 24620 headers = vNode[property]; -1 24621 break; -1 24622 } -1 24623 cells.push(cell); -1 24624 } -1 24625 } -1 24626 headers = (headers || []).concat(cells.filter(predicate)); -1 24627 cells.forEach(function(tableCell) { -1 24628 var vNode = axe.utils.getNodeFromTree(tableCell); -1 24629 vNode[property] = headers; -1 24630 }); -1 24631 return headers; -1 24632 } -1 24633 function getHeaders(cell, tableGrid) { -1 24634 if (cell.getAttribute('headers')) { -1 24635 var headers = idrefs_default(cell, 'headers'); -1 24636 if (headers.filter(function(header) { -1 24637 return header; -1 24638 }).length) { -1 24639 return headers; -1 24640 } -1 24641 } -1 24642 if (!tableGrid) { -1 24643 tableGrid = to_grid_default(find_up_default(cell, 'table')); -1 24644 } -1 24645 var position = get_cell_position_default(cell, tableGrid); -1 24646 var rowHeaders = traverseForHeaders('row', position, tableGrid); -1 24647 var colHeaders = traverseForHeaders('col', position, tableGrid); -1 24648 return [].concat(rowHeaders, colHeaders).reverse(); -1 24649 } -1 24650 var get_headers_default = getHeaders; -1 24651 function isDataCell(cell) { -1 24652 if (!cell.children.length && !cell.textContent.trim()) { -1 24653 return false; -1 24654 } -1 24655 var role = cell.getAttribute('role'); -1 24656 if (is_valid_role_default(role)) { -1 24657 return [ 'cell', 'gridcell' ].includes(role); -1 24658 } else { -1 24659 return cell.nodeName.toUpperCase() === 'TD'; -1 24660 } -1 24661 } -1 24662 var is_data_cell_default = isDataCell; -1 24663 function isDataTable(node) { -1 24664 var role = (node.getAttribute('role') || '').toLowerCase(); -1 24665 if ((role === 'presentation' || role === 'none') && !is_focusable_default(node)) { -1 24666 return false; -1 24667 } -1 24668 if (node.getAttribute('contenteditable') === 'true' || find_up_default(node, '[contenteditable="true"]')) { -1 24669 return true; -1 24670 } -1 24671 if (role === 'grid' || role === 'treegrid' || role === 'table') { -1 24672 return true; -1 24673 } -1 24674 if (get_role_type_default(role) === 'landmark') { -1 24675 return true; -1 24676 } -1 24677 if (node.getAttribute('datatable') === '0') { -1 24678 return false; -1 24679 } -1 24680 if (node.getAttribute('summary')) { -1 24681 return true; -1 24682 } -1 24683 if (node.tHead || node.tFoot || node.caption) { -1 24684 return true; -1 24685 } -1 24686 for (var childIndex = 0, childLength = node.children.length; childIndex < childLength; childIndex++) { -1 24687 if (node.children[childIndex].nodeName.toUpperCase() === 'COLGROUP') { -1 24688 return true; -1 24689 } -1 24690 } -1 24691 var cells = 0; -1 24692 var rowLength = node.rows.length; -1 24693 var row, cell; -1 24694 var hasBorder = false; -1 24695 for (var rowIndex = 0; rowIndex < rowLength; rowIndex++) { -1 24696 row = node.rows[rowIndex]; -1 24697 for (var cellIndex = 0, cellLength = row.cells.length; cellIndex < cellLength; cellIndex++) { -1 24698 cell = row.cells[cellIndex]; -1 24699 if (cell.nodeName.toUpperCase() === 'TH') { -1 24700 return true; -1 24701 } -1 24702 if (!hasBorder && (cell.offsetWidth !== cell.clientWidth || cell.offsetHeight !== cell.clientHeight)) { -1 24703 hasBorder = true; -1 24704 } -1 24705 if (cell.getAttribute('scope') || cell.getAttribute('headers') || cell.getAttribute('abbr')) { -1 24706 return true; -1 24707 } -1 24708 if ([ 'columnheader', 'rowheader' ].includes((cell.getAttribute('role') || '').toLowerCase())) { -1 24709 return true; -1 24710 } -1 24711 if (cell.children.length === 1 && cell.children[0].nodeName.toUpperCase() === 'ABBR') { -1 24712 return true; -1 24713 } -1 24714 cells++; -1 24715 } -1 24716 } -1 24717 if (node.getElementsByTagName('table').length) { -1 24718 return false; -1 24719 } -1 24720 if (rowLength < 2) { -1 24721 return false; -1 24722 } -1 24723 var sampleRow = node.rows[Math.ceil(rowLength / 2)]; -1 24724 if (sampleRow.cells.length === 1 && sampleRow.cells[0].colSpan === 1) { -1 24725 return false; -1 24726 } -1 24727 if (sampleRow.cells.length >= 5) { -1 24728 return true; -1 24729 } -1 24730 if (hasBorder) { -1 24731 return true; -1 24732 } -1 24733 var bgColor, bgImage; -1 24734 for (rowIndex = 0; rowIndex < rowLength; rowIndex++) { -1 24735 row = node.rows[rowIndex]; -1 24736 if (bgColor && bgColor !== window.getComputedStyle(row).getPropertyValue('background-color')) { -1 24737 return true; -1 24738 } else { -1 24739 bgColor = window.getComputedStyle(row).getPropertyValue('background-color'); -1 24740 } -1 24741 if (bgImage && bgImage !== window.getComputedStyle(row).getPropertyValue('background-image')) { -1 24742 return true; -1 24743 } else { -1 24744 bgImage = window.getComputedStyle(row).getPropertyValue('background-image'); -1 24745 } -1 24746 } -1 24747 if (rowLength >= 20) { -1 24748 return true; -1 24749 } -1 24750 if (get_element_coordinates_default(node).width > get_viewport_size_default(window).width * .95) { -1 24751 return false; -1 24752 } -1 24753 if (cells < 10) { -1 24754 return false; -1 24755 } -1 24756 if (node.querySelector('object, embed, iframe, applet')) { -1 24757 return false; -1 24758 } -1 24759 return true; 49713 24760 }49714 -1 var identical_links_same_purpose_after_default = identicalLinksSamePurposeAfter;49715 -1 var commons_exports = {};49716 -1 __export(commons_exports, {49717 -1 aria: function aria() {49718 -1 return aria_exports;49719 -1 },49720 -1 color: function color() {49721 -1 return color_exports;49722 -1 },49723 -1 dom: function dom() {49724 -1 return dom_exports;49725 -1 },49726 -1 forms: function forms() {49727 -1 return forms_exports;49728 -1 },49729 -1 matches: function matches() {49730 -1 return matches_default3;49731 -1 },49732 -1 standards: function standards() {49733 -1 return standards_exports;49734 -1 },49735 -1 table: function table() {49736 -1 return table_exports;49737 -1 },49738 -1 text: function text() {49739 -1 return text_exports;49740 -1 },49741 -1 utils: function utils() {49742 -1 return utils_exports;-1 24761 var is_data_table_default = isDataTable; -1 24762 function isHeader(cell) { -1 24763 if (is_column_header_default(cell) || is_row_header_default(cell)) { -1 24764 return true; 49743 24765 }49744 -1 });49745 -1 var forms_exports = {};49746 -1 __export(forms_exports, {49747 -1 isAriaCombobox: function isAriaCombobox() {49748 -1 return is_aria_combobox_default;49749 -1 },49750 -1 isAriaListbox: function isAriaListbox() {49751 -1 return is_aria_listbox_default;49752 -1 },49753 -1 isAriaRange: function isAriaRange() {49754 -1 return is_aria_range_default;49755 -1 },49756 -1 isAriaTextbox: function isAriaTextbox() {49757 -1 return is_aria_textbox_default;49758 -1 },49759 -1 isDisabled: function isDisabled() {49760 -1 return is_disabled_default;49761 -1 },49762 -1 isNativeSelect: function isNativeSelect() {49763 -1 return is_native_select_default;49764 -1 },49765 -1 isNativeTextbox: function isNativeTextbox() {49766 -1 return is_native_textbox_default;-1 24766 if (cell.getAttribute('id')) { -1 24767 var id = escape_selector_default(cell.getAttribute('id')); -1 24768 return !!document.querySelector('[headers~="'.concat(id, '"]')); 49767 24769 }49768 -1 });49769 -1 var disabledNodeNames = [ 'fieldset', 'button', 'select', 'input', 'textarea' ];49770 -1 function isDisabled(virtualNode) {49771 -1 var disabledState = virtualNode._isDisabled;49772 -1 if (typeof disabledState === 'boolean') {49773 -1 return disabledState;-1 24770 return false; -1 24771 } -1 24772 var is_header_default = isHeader; -1 24773 function traverseTable(dir, position, tableGrid, callback) { -1 24774 var result; -1 24775 var cell = tableGrid[position.y] ? tableGrid[position.y][position.x] : void 0; -1 24776 if (!cell) { -1 24777 return []; 49774 24778 }49775 -1 var nodeName2 = virtualNode.props.nodeName;49776 -1 var ariaDisabled = virtualNode.attr('aria-disabled');49777 -1 if (disabledNodeNames.includes(nodeName2) && virtualNode.hasAttr('disabled')) {49778 -1 disabledState = true;49779 -1 } else if (ariaDisabled) {49780 -1 disabledState = ariaDisabled.toLowerCase() === 'true';49781 -1 } else if (virtualNode.parent) {49782 -1 disabledState = isDisabled(virtualNode.parent);49783 -1 } else {49784 -1 disabledState = false;-1 24779 if (typeof callback === 'function') { -1 24780 result = callback(cell, position, tableGrid); -1 24781 if (result === true) { -1 24782 return [ cell ]; -1 24783 } 49785 24784 }49786 -1 virtualNode._isDisabled = disabledState;49787 -1 return disabledState;-1 24785 result = traverseTable(dir, { -1 24786 x: position.x + dir.x, -1 24787 y: position.y + dir.y -1 24788 }, tableGrid, callback); -1 24789 result.unshift(cell); -1 24790 return result; 49788 24791 }49789 -1 var is_disabled_default = isDisabled;-1 24792 function traverse(dir, startPos, tableGrid, callback) { -1 24793 if (Array.isArray(startPos)) { -1 24794 callback = tableGrid; -1 24795 tableGrid = startPos; -1 24796 startPos = { -1 24797 x: 0, -1 24798 y: 0 -1 24799 }; -1 24800 } -1 24801 if (typeof dir === 'string') { -1 24802 switch (dir) { -1 24803 case 'left': -1 24804 dir = { -1 24805 x: -1, -1 24806 y: 0 -1 24807 }; -1 24808 break; -1 24809 -1 24810 case 'up': -1 24811 dir = { -1 24812 x: 0, -1 24813 y: -1 -1 24814 }; -1 24815 break; -1 24816 -1 24817 case 'right': -1 24818 dir = { -1 24819 x: 1, -1 24820 y: 0 -1 24821 }; -1 24822 break; -1 24823 -1 24824 case 'down': -1 24825 dir = { -1 24826 x: 0, -1 24827 y: 1 -1 24828 }; -1 24829 break; -1 24830 } -1 24831 } -1 24832 return traverseTable(dir, { -1 24833 x: startPos.x + dir.x, -1 24834 y: startPos.y + dir.y -1 24835 }, tableGrid, callback); -1 24836 } -1 24837 var traverse_default = traverse; 49790 24838 var commons = { 49791 24839 aria: aria_exports, 49792 24840 color: color_exports, @@ -49820,7 +24868,7 @@ module.exports = { 49820 24868 function internalLinkPresentEvaluate(node, options, virtualNode) { 49821 24869 var links = query_selector_all_default(virtualNode, 'a[href]'); 49822 24870 return links.some(function(vLink) {49823 -1 return /^#[^/!]/.test(vLink.actualNode.getAttribute('href'));-1 24871 return /^#[^/!]/.test(vLink.attr('href')); 49824 24872 }); 49825 24873 } 49826 24874 var internal_link_present_evaluate_default = internalLinkPresentEvaluate; @@ -49851,16 +24899,16 @@ module.exports = { 49851 24899 var outerText = elm.textContent.trim(); 49852 24900 var innerText = outerText; 49853 24901 while (innerText === outerText && nextNode !== void 0) {49854 -1 var _i20 = -1;-1 24902 var _i22 = -1; 49855 24903 elm = nextNode; 49856 24904 if (elm.children.length === 0) { 49857 24905 return elm; 49858 24906 } 49859 24907 do {49860 -1 _i20++;49861 -1 innerText = elm.children[_i20].textContent.trim();49862 -1 } while (innerText === '' && _i20 + 1 < elm.children.length);49863 -1 nextNode = elm.children[_i20];-1 24908 _i22++; -1 24909 innerText = elm.children[_i22].textContent.trim(); -1 24910 } while (innerText === '' && _i22 + 1 < elm.children.length); -1 24911 nextNode = elm.children[_i22]; 49864 24912 } 49865 24913 return elm; 49866 24914 } @@ -49891,6 +24939,13 @@ module.exports = { 49891 24939 var currStyle = getStyleValues(node); 49892 24940 var nextStyle = nextSibling ? getStyleValues(nextSibling) : null; 49893 24941 var prevStyle = prevSibling ? getStyleValues(prevSibling) : null; -1 24942 var optionsPassLength = options.passLength; -1 24943 var optionsFailLength = options.failLength; -1 24944 var headingLength = node.textContent.trim().length; -1 24945 var paragraphLength = nextSibling === null || nextSibling === void 0 ? void 0 : nextSibling.textContent.trim().length; -1 24946 if (headingLength > paragraphLength * optionsPassLength) { -1 24947 return true; -1 24948 } 49894 24949 if (!nextStyle || !isHeaderStyle(currStyle, nextStyle, margins)) { 49895 24950 return true; 49896 24951 } @@ -49901,10 +24956,45 @@ module.exports = { 49901 24956 if (prevStyle && !isHeaderStyle(currStyle, prevStyle, margins)) { 49902 24957 return void 0; 49903 24958 } -1 24959 if (headingLength > paragraphLength * optionsFailLength) { -1 24960 return void 0; -1 24961 } 49904 24962 return false; 49905 24963 } 49906 24964 var p_as_heading_evaluate_default = pAsHeadingEvaluate;49907 -1 var landmarkRoles = get_aria_roles_by_type_default('landmark');-1 24965 function regionAfter(results) { -1 24966 var iframeResults = results.filter(function(r) { -1 24967 return r.data.isIframe; -1 24968 }); -1 24969 results.forEach(function(r) { -1 24970 if (r.result || r.node.ancestry.length === 1) { -1 24971 return; -1 24972 } -1 24973 var frameAncestry = r.node.ancestry.slice(0, -1); -1 24974 var _iterator2 = _createForOfIteratorHelper(iframeResults), _step2; -1 24975 try { -1 24976 for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) { -1 24977 var iframeResult = _step2.value; -1 24978 if (match_ancestry_default(frameAncestry, iframeResult.node.ancestry)) { -1 24979 r.result = iframeResult.result; -1 24980 break; -1 24981 } -1 24982 } -1 24983 } catch (err) { -1 24984 _iterator2.e(err); -1 24985 } finally { -1 24986 _iterator2.f(); -1 24987 } -1 24988 }); -1 24989 iframeResults.forEach(function(r) { -1 24990 if (!r.result) { -1 24991 r.result = true; -1 24992 } -1 24993 }); -1 24994 return results; -1 24995 } -1 24996 var region_after_default = regionAfter; -1 24997 var landmarkRoles2 = get_aria_roles_by_type_default('landmark'); 49908 24998 var implicitAriaLiveRoles = [ 'alert', 'log', 'status' ]; 49909 24999 function isRegion(virtualNode, options) { 49910 25000 var node = virtualNode.actualNode; @@ -49913,7 +25003,7 @@ module.exports = { 49913 25003 if ([ 'assertive', 'polite' ].includes(ariaLive) || implicitAriaLiveRoles.includes(role)) { 49914 25004 return true; 49915 25005 }49916 -1 if (landmarkRoles.includes(role)) {-1 25006 if (landmarkRoles2.includes(role)) { 49917 25007 return true; 49918 25008 } 49919 25009 if (options.regionMatcher && matches_default3(virtualNode, options.regionMatcher)) { @@ -49923,18 +25013,21 @@ module.exports = { 49923 25013 } 49924 25014 function findRegionlessElms(virtualNode, options) { 49925 25015 var node = virtualNode.actualNode;49926 -1 if (isRegion(virtualNode, options) || is_skip_link_default(virtualNode.actualNode) && get_element_by_reference_default(virtualNode.actualNode, 'href') || !is_visible_default(node, true)) {-1 25016 if (get_role_default(virtualNode) === 'button' || isRegion(virtualNode, options) || [ 'iframe', 'frame' ].includes(virtualNode.props.nodeName) || _isSkipLink(virtualNode.actualNode) && get_element_by_reference_default(virtualNode.actualNode, 'href') || !is_visible_default(node, true)) { 49927 25017 var vNode = virtualNode; 49928 25018 while (vNode) { 49929 25019 vNode._hasRegionDescendant = true; 49930 25020 vNode = vNode.parent; 49931 25021 } -1 25022 if ([ 'iframe', 'frame' ].includes(virtualNode.props.nodeName)) { -1 25023 return [ virtualNode ]; -1 25024 } 49932 25025 return []; 49933 25026 } else if (node !== document.body && has_content_default(node, true)) { 49934 25027 return [ virtualNode ]; 49935 25028 } else {49936 -1 return virtualNode.children.filter(function(_ref55) {49937 -1 var actualNode = _ref55.actualNode;-1 25029 return virtualNode.children.filter(function(_ref83) { -1 25030 var actualNode = _ref83.actualNode; 49938 25031 return actualNode.nodeType === 1; 49939 25032 }).map(function(vNode) { 49940 25033 return findRegionlessElms(vNode, options); @@ -49943,375 +25036,52 @@ module.exports = { 49943 25036 }, []); 49944 25037 } 49945 25038 }49946 -1 function regionEvaluate(node, options, virtualNode) {49947 -1 var regionlessNodes = cache_default.get('regionlessNodes');49948 -1 if (regionlessNodes) {49949 -1 return !regionlessNodes.includes(virtualNode);49950 -1 }49951 -1 var tree = axe._tree;49952 -1 regionlessNodes = findRegionlessElms(tree[0], options).map(function(vNode) {49953 -1 while (vNode.parent && !vNode.parent._hasRegionDescendant && vNode.parent.actualNode !== document.body) {49954 -1 vNode = vNode.parent;49955 -1 }49956 -1 return vNode;49957 -1 }).filter(function(vNode, index, array) {49958 -1 return array.indexOf(vNode) === index;49959 -1 });49960 -1 cache_default.set('regionlessNodes', regionlessNodes);49961 -1 return !regionlessNodes.includes(virtualNode);49962 -1 }49963 -1 var region_evaluate_default = regionEvaluate;49964 -1 function skipLinkEvaluate(node) {49965 -1 var target = get_element_by_reference_default(node, 'href');49966 -1 if (target) {49967 -1 return is_visible_default(target, true) || void 0;49968 -1 }49969 -1 return false;49970 -1 }49971 -1 var skip_link_evaluate_default = skipLinkEvaluate;49972 -1 function uniqueFrameTitleAfter(results) {49973 -1 var titles = {};49974 -1 results.forEach(function(r) {49975 -1 titles[r.data] = titles[r.data] !== void 0 ? ++titles[r.data] : 0;49976 -1 });49977 -1 results.forEach(function(r) {49978 -1 r.result = !!titles[r.data];49979 -1 });49980 -1 return results;49981 -1 }49982 -1 var unique_frame_title_after_default = uniqueFrameTitleAfter;49983 -1 function uniqueFrameTitleEvaluate(node, options, vNode) {49984 -1 var title = sanitize_default(vNode.attr('title')).toLowerCase();49985 -1 this.data(title);49986 -1 return true;49987 -1 }49988 -1 var unique_frame_title_evaluate_default = uniqueFrameTitleEvaluate;49989 -1 function ariaLabelEvaluate(node, options, virtualNode) {49990 -1 return !!sanitize_default(arialabel_text_default(virtualNode));49991 -1 }49992 -1 var aria_label_evaluate_default = ariaLabelEvaluate;49993 -1 function ariaLabelledbyEvaluate(node, options, virtualNode) {49994 -1 try {49995 -1 return !!sanitize_default(arialabelledby_text_default(virtualNode));49996 -1 } catch (e) {49997 -1 return void 0;49998 -1 }49999 -1 }50000 -1 var aria_labelledby_evaluate_default = ariaLabelledbyEvaluate;50001 -1 function avoidInlineSpacingEvaluate(node, options) {50002 -1 var overriddenProperties = options.cssProperties.filter(function(property) {50003 -1 if (node.style.getPropertyPriority(property) === 'important') {50004 -1 return property;50005 -1 }50006 -1 });50007 -1 if (overriddenProperties.length > 0) {50008 -1 this.data(overriddenProperties);50009 -1 return false;50010 -1 }50011 -1 return true;50012 -1 }50013 -1 var avoid_inline_spacing_evaluate_default = avoidInlineSpacingEvaluate;50014 -1 function docHasTitleEvaluate() {50015 -1 var title = document.title;50016 -1 return !!sanitize_default(title);50017 -1 }50018 -1 var doc_has_title_evaluate_default = docHasTitleEvaluate;50019 -1 function existsEvaluate() {50020 -1 return void 0;50021 -1 }50022 -1 var exists_evaluate_default = existsEvaluate;50023 -1 function hasAltEvaluate(node, options, virtualNode) {50024 -1 var nodeName2 = virtualNode.props.nodeName;50025 -1 if (![ 'img', 'input', 'area' ].includes(nodeName2)) {50026 -1 return false;50027 -1 }50028 -1 return virtualNode.hasAttr('alt');50029 -1 }50030 -1 var has_alt_evaluate_default = hasAltEvaluate;50031 -1 function isOnScreenEvaluate(node) {50032 -1 return is_visible_default(node, false) && !is_offscreen_default(node);50033 -1 }50034 -1 var is_on_screen_evaluate_default = isOnScreenEvaluate;50035 -1 function nonEmptyIfPresentEvaluate(node, options, virtualNode) {50036 -1 var nodeName2 = virtualNode.props.nodeName;50037 -1 var type = (virtualNode.attr('type') || '').toLowerCase();50038 -1 var label5 = virtualNode.attr('value');50039 -1 if (label5) {50040 -1 this.data({50041 -1 messageKey: 'has-label'50042 -1 });50043 -1 }50044 -1 if (nodeName2 === 'input' && [ 'submit', 'reset' ].includes(type)) {50045 -1 return label5 === null;50046 -1 }50047 -1 return false;50048 -1 }50049 -1 var non_empty_if_present_evaluate_default = nonEmptyIfPresentEvaluate;50050 -1 function presentationalRoleEvaluate(node, options, virtualNode) {50051 -1 var role = get_role_default(virtualNode);50052 -1 var explicitRole2 = get_explicit_role_default(virtualNode);50053 -1 if ([ 'presentation', 'none' ].includes(role)) {50054 -1 this.data({50055 -1 role: role50056 -1 });50057 -1 return true;50058 -1 }50059 -1 if (![ 'presentation', 'none' ].includes(explicitRole2)) {50060 -1 return false;50061 -1 }50062 -1 var hasGlobalAria = get_global_aria_attrs_default().some(function(attr) {50063 -1 return virtualNode.hasAttr(attr);50064 -1 });50065 -1 var focusable = is_focusable_default(virtualNode);50066 -1 var messageKey;50067 -1 if (hasGlobalAria && !focusable) {50068 -1 messageKey = 'globalAria';50069 -1 } else if (!hasGlobalAria && focusable) {50070 -1 messageKey = 'focusable';50071 -1 } else {50072 -1 messageKey = 'both';50073 -1 }50074 -1 this.data({50075 -1 messageKey: messageKey,50076 -1 role: role50077 -1 });50078 -1 return false;50079 -1 }50080 -1 var presentational_role_evaluate_default = presentationalRoleEvaluate;50081 -1 function svgNonEmptyTitleEvaluate(node, options, virtualNode) {50082 -1 if (!virtualNode.children) {50083 -1 return void 0;50084 -1 }50085 -1 var titleNode = virtualNode.children.find(function(_ref56) {50086 -1 var props = _ref56.props;50087 -1 return props.nodeName === 'title';50088 -1 });50089 -1 if (!titleNode) {50090 -1 this.data({50091 -1 messageKey: 'noTitle'50092 -1 });50093 -1 return false;50094 -1 }50095 -1 try {50096 -1 if (visible_virtual_default(titleNode) === '') {50097 -1 this.data({50098 -1 messageKey: 'emptyTitle'50099 -1 });50100 -1 return false;50101 -1 }50102 -1 } catch (e) {50103 -1 return void 0;50104 -1 }50105 -1 return true;50106 -1 }50107 -1 var svg_non_empty_title_evaluate_default = svgNonEmptyTitleEvaluate;50108 -1 function cssOrientationLockEvaluate(node, options, virtualNode, context3) {50109 -1 var _ref57 = context3 || {}, _ref57$cssom = _ref57.cssom, cssom = _ref57$cssom === void 0 ? void 0 : _ref57$cssom;50110 -1 var _ref58 = options || {}, _ref58$degreeThreshol = _ref58.degreeThreshold, degreeThreshold = _ref58$degreeThreshol === void 0 ? 0 : _ref58$degreeThreshol;50111 -1 if (!cssom || !cssom.length) {50112 -1 return void 0;50113 -1 }50114 -1 var isLocked = false;50115 -1 var relatedElements = [];50116 -1 var rulesGroupByDocumentFragment = groupCssomByDocument(cssom);50117 -1 var _loop6 = function _loop6() {50118 -1 var key = _Object$keys2[_i21];50119 -1 var _rulesGroupByDocument = rulesGroupByDocumentFragment[key], root = _rulesGroupByDocument.root, rules = _rulesGroupByDocument.rules;50120 -1 var orientationRules = rules.filter(isMediaRuleWithOrientation);50121 -1 if (!orientationRules.length) {50122 -1 return 'continue';50123 -1 }50124 -1 orientationRules.forEach(function(_ref59) {50125 -1 var cssRules = _ref59.cssRules;50126 -1 Array.from(cssRules).forEach(function(cssRule) {50127 -1 var locked = getIsOrientationLocked(cssRule);50128 -1 if (locked && cssRule.selectorText.toUpperCase() !== 'HTML') {50129 -1 var elms = Array.from(root.querySelectorAll(cssRule.selectorText)) || [];50130 -1 relatedElements = relatedElements.concat(elms);50131 -1 }50132 -1 isLocked = isLocked || locked;50133 -1 });50134 -1 });50135 -1 };50136 -1 for (var _i21 = 0, _Object$keys2 = Object.keys(rulesGroupByDocumentFragment); _i21 < _Object$keys2.length; _i21++) {50137 -1 var _ret3 = _loop6();50138 -1 if (_ret3 === 'continue') {50139 -1 continue;50140 -1 }50141 -1 }50142 -1 if (!isLocked) {50143 -1 return true;50144 -1 }50145 -1 if (relatedElements.length) {50146 -1 this.relatedNodes(relatedElements);50147 -1 }50148 -1 return false;50149 -1 function groupCssomByDocument(cssObjectModel) {50150 -1 return cssObjectModel.reduce(function(out, _ref60) {50151 -1 var sheet = _ref60.sheet, root = _ref60.root, shadowId = _ref60.shadowId;50152 -1 var key = shadowId ? shadowId : 'topDocument';50153 -1 if (!out[key]) {50154 -1 out[key] = {50155 -1 root: root,50156 -1 rules: []50157 -1 };50158 -1 }50159 -1 if (!sheet || !sheet.cssRules) {50160 -1 return out;50161 -1 }50162 -1 var rules = Array.from(sheet.cssRules);50163 -1 out[key].rules = out[key].rules.concat(rules);50164 -1 return out;50165 -1 }, {});50166 -1 }50167 -1 function isMediaRuleWithOrientation(_ref61) {50168 -1 var type = _ref61.type, cssText = _ref61.cssText;50169 -1 if (type !== 4) {50170 -1 return false;50171 -1 }50172 -1 return /orientation:\s*landscape/i.test(cssText) || /orientation:\s*portrait/i.test(cssText);50173 -1 }50174 -1 function getIsOrientationLocked(_ref62) {50175 -1 var selectorText = _ref62.selectorText, style = _ref62.style;50176 -1 if (!selectorText || style.length <= 0) {50177 -1 return false;50178 -1 }50179 -1 var transformStyle = style.transform || style.webkitTransform || style.msTransform || false;50180 -1 if (!transformStyle) {50181 -1 return false;50182 -1 }50183 -1 var matches14 = transformStyle.match(/(rotate|rotateZ|rotate3d|matrix|matrix3d)\(([^)]+)\)(?!.*(rotate|rotateZ|rotate3d|matrix|matrix3d))/);50184 -1 if (!matches14) {50185 -1 return false;50186 -1 }50187 -1 var _matches = _slicedToArray(matches14, 3), transformFn = _matches[1], transformFnValue = _matches[2];50188 -1 var degrees = getRotationInDegrees(transformFn, transformFnValue);50189 -1 if (!degrees) {50190 -1 return false;50191 -1 }50192 -1 degrees = Math.abs(degrees);50193 -1 if (Math.abs(degrees - 180) % 180 <= degreeThreshold) {50194 -1 return false;50195 -1 }50196 -1 return Math.abs(degrees - 90) % 90 <= degreeThreshold;50197 -1 }50198 -1 function getRotationInDegrees(transformFunction, transformFnValue) {50199 -1 switch (transformFunction) {50200 -1 case 'rotate':50201 -1 case 'rotateZ':50202 -1 return getAngleInDegrees(transformFnValue);50203 -150204 -1 case 'rotate3d':50205 -1 var _transformFnValue$spl = transformFnValue.split(',').map(function(value) {50206 -1 return value.trim();50207 -1 }), _transformFnValue$spl2 = _slicedToArray(_transformFnValue$spl, 4), z = _transformFnValue$spl2[2], angleWithUnit = _transformFnValue$spl2[3];50208 -1 if (parseInt(z) === 0) {50209 -1 return;50210 -1 }50211 -1 return getAngleInDegrees(angleWithUnit);50212 -150213 -1 case 'matrix':50214 -1 case 'matrix3d':50215 -1 return getAngleInDegreesFromMatrixTransform(transformFnValue);50216 -150217 -1 default:50218 -1 return;50219 -1 }50220 -1 }50221 -1 function getAngleInDegrees(angleWithUnit) {50222 -1 var _ref63 = angleWithUnit.match(/(deg|grad|rad|turn)/) || [], _ref64 = _slicedToArray(_ref63, 1), unit = _ref64[0];50223 -1 if (!unit) {50224 -1 return;50225 -1 }50226 -1 var angle = parseFloat(angleWithUnit.replace(unit, ''));50227 -1 switch (unit) {50228 -1 case 'rad':50229 -1 return convertRadToDeg(angle);50230 -150231 -1 case 'grad':50232 -1 return convertGradToDeg(angle);50233 -150234 -1 case 'turn':50235 -1 return convertTurnToDeg(angle);50236 -150237 -1 case 'deg':50238 -1 default:50239 -1 return parseInt(angle);50240 -1 }50241 -1 }50242 -1 function getAngleInDegreesFromMatrixTransform(transformFnValue) {50243 -1 var values = transformFnValue.split(',');50244 -1 if (values.length <= 6) {50245 -1 var _values = _slicedToArray(values, 2), a = _values[0], b2 = _values[1];50246 -1 var radians = Math.atan2(parseFloat(b2), parseFloat(a));50247 -1 return convertRadToDeg(radians);50248 -1 }50249 -1 var sinB = parseFloat(values[8]);50250 -1 var b = Math.asin(sinB);50251 -1 var cosB = Math.cos(b);50252 -1 var rotateZRadians = Math.acos(parseFloat(values[0]) / cosB);50253 -1 return convertRadToDeg(rotateZRadians);50254 -1 }50255 -1 function convertRadToDeg(radians) {50256 -1 return Math.round(radians * (180 / Math.PI));50257 -1 }50258 -1 function convertGradToDeg(grad) {50259 -1 grad = grad % 400;50260 -1 if (grad < 0) {50261 -1 grad += 400;50262 -1 }50263 -1 return Math.round(grad / 400 * 360);50264 -1 }50265 -1 function convertTurnToDeg(turn) {50266 -1 return Math.round(360 / (1 / turn));50267 -1 }50268 -1 }50269 -1 var css_orientation_lock_evaluate_default = cssOrientationLockEvaluate;50270 -1 function metaViewportScaleEvaluate(node, options, virtualNode) {50271 -1 var _ref65 = options || {}, _ref65$scaleMinimum = _ref65.scaleMinimum, scaleMinimum = _ref65$scaleMinimum === void 0 ? 2 : _ref65$scaleMinimum, _ref65$lowerBound = _ref65.lowerBound, lowerBound = _ref65$lowerBound === void 0 ? false : _ref65$lowerBound;50272 -1 var content = virtualNode.attr('content') || '';50273 -1 if (!content) {50274 -1 return true;50275 -1 }50276 -1 var result = content.split(/[;,]/).reduce(function(out, item) {50277 -1 var contentValue = item.trim();50278 -1 if (!contentValue) {50279 -1 return out;50280 -1 }50281 -1 var _contentValue$split = contentValue.split('='), _contentValue$split2 = _slicedToArray(_contentValue$split, 2), key = _contentValue$split2[0], value = _contentValue$split2[1];50282 -1 if (!key || !value) {50283 -1 return out;50284 -1 }50285 -1 var curatedKey = key.toLowerCase().trim();50286 -1 var curatedValue = value.toLowerCase().trim();50287 -1 if (curatedKey === 'maximum-scale' && curatedValue === 'yes') {50288 -1 curatedValue = 1;50289 -1 }50290 -1 if (curatedKey === 'maximum-scale' && parseFloat(curatedValue) < 0) {50291 -1 return out;50292 -1 }50293 -1 out[curatedKey] = curatedValue;50294 -1 return out;50295 -1 }, {});50296 -1 if (lowerBound && result['maximum-scale'] && parseFloat(result['maximum-scale']) < lowerBound) {50297 -1 return true;50298 -1 }50299 -1 if (!lowerBound && result['user-scalable'] === 'no') {50300 -1 this.data('user-scalable=no');50301 -1 return false;50302 -1 }50303 -1 var userScalableAsFloat = parseFloat(result['user-scalable']);50304 -1 if (!lowerBound && result['user-scalable'] && (userScalableAsFloat || userScalableAsFloat === 0) && userScalableAsFloat > -1 && userScalableAsFloat < 1) {50305 -1 this.data('user-scalable');50306 -1 return false;-1 25039 function regionEvaluate(node, options, virtualNode) { -1 25040 var regionlessNodes = cache_default.get('regionlessNodes'); -1 25041 this.data({ -1 25042 isIframe: [ 'iframe', 'frame' ].includes(virtualNode.props.nodeName) -1 25043 }); -1 25044 if (regionlessNodes) { -1 25045 return !regionlessNodes.includes(virtualNode); 50307 25046 }50308 -1 if (result['maximum-scale'] && parseFloat(result['maximum-scale']) < scaleMinimum) {50309 -1 this.data('maximum-scale');50310 -1 return false;-1 25047 var tree = axe._tree; -1 25048 regionlessNodes = findRegionlessElms(tree[0], options).map(function(vNode) { -1 25049 while (vNode.parent && !vNode.parent._hasRegionDescendant && vNode.parent.actualNode !== document.body) { -1 25050 vNode = vNode.parent; -1 25051 } -1 25052 return vNode; -1 25053 }).filter(function(vNode, index, array) { -1 25054 return array.indexOf(vNode) === index; -1 25055 }); -1 25056 cache_default.set('regionlessNodes', regionlessNodes); -1 25057 return !regionlessNodes.includes(virtualNode); -1 25058 } -1 25059 var region_evaluate_default = regionEvaluate; -1 25060 function skipLinkEvaluate(node) { -1 25061 var target = get_element_by_reference_default(node, 'href'); -1 25062 if (target) { -1 25063 return is_visible_default(target, true) || void 0; 50311 25064 } -1 25065 return false; -1 25066 } -1 25067 var skip_link_evaluate_default = skipLinkEvaluate; -1 25068 function uniqueFrameTitleAfter(results) { -1 25069 var titles = {}; -1 25070 results.forEach(function(r) { -1 25071 titles[r.data] = titles[r.data] !== void 0 ? ++titles[r.data] : 0; -1 25072 }); -1 25073 results.forEach(function(r) { -1 25074 r.result = !!titles[r.data]; -1 25075 }); -1 25076 return results; -1 25077 } -1 25078 var unique_frame_title_after_default = uniqueFrameTitleAfter; -1 25079 function uniqueFrameTitleEvaluate(node, options, vNode) { -1 25080 var title = sanitize_default(vNode.attr('title')).toLowerCase(); -1 25081 this.data(title); 50312 25082 return true; 50313 25083 }50314 -1 var meta_viewport_scale_evaluate_default = metaViewportScaleEvaluate;-1 25084 var unique_frame_title_evaluate_default = uniqueFrameTitleEvaluate; 50315 25085 function duplicateIdAfter(results) { 50316 25086 var uniqueIds = []; 50317 25087 return results.filter(function(r) { @@ -50339,677 +25109,292 @@ module.exports = { 50339 25109 return matchingNodes.length === 0; 50340 25110 } 50341 25111 var duplicate_id_evaluate_default = duplicateIdEvaluate;50342 -1 function accesskeysAfter(results) {50343 -1 var seen = {};50344 -1 return results.filter(function(r) {50345 -1 if (!r.data) {50346 -1 return false;50347 -1 }50348 -1 var key = r.data.toUpperCase();50349 -1 if (!seen[key]) {50350 -1 seen[key] = r;50351 -1 r.relatedNodes = [];50352 -1 return true;50353 -1 }50354 -1 seen[key].relatedNodes.push(r.relatedNodes[0]);50355 -1 return false;50356 -1 }).map(function(r) {50357 -1 r.result = !!r.relatedNodes.length;50358 -1 return r;50359 -1 });50360 -1 }50361 -1 var accesskeys_after_default = accesskeysAfter;50362 -1 function accesskeysEvaluate(node) {50363 -1 if (is_visible_default(node, false)) {50364 -1 this.data(node.getAttribute('accesskey'));50365 -1 this.relatedNodes([ node ]);50366 -1 }50367 -1 return true;50368 -1 }50369 -1 var accesskeys_evaluate_default = accesskeysEvaluate;50370 -1 function focusableContentEvaluate(node, options, virtualNode) {50371 -1 var tabbableElements = virtualNode.tabbableElements;50372 -1 if (!tabbableElements) {50373 -1 return false;50374 -1 }50375 -1 var tabbableContentElements = tabbableElements.filter(function(el) {50376 -1 return el !== virtualNode;50377 -1 });50378 -1 return tabbableContentElements.length > 0;50379 -1 }50380 -1 var focusable_content_evaluate_default = focusableContentEvaluate;50381 -1 function focusableDisabledEvaluate(node, options, virtualNode) {50382 -1 var elementsThatCanBeDisabled = [ 'BUTTON', 'FIELDSET', 'INPUT', 'SELECT', 'TEXTAREA' ];50383 -1 var tabbableElements = virtualNode.tabbableElements;50384 -1 if (!tabbableElements || !tabbableElements.length) {50385 -1 return true;50386 -1 }50387 -1 var relatedNodes = tabbableElements.reduce(function(out, _ref66) {50388 -1 var el = _ref66.actualNode;50389 -1 var nodeName2 = el.nodeName.toUpperCase();50390 -1 if (elementsThatCanBeDisabled.includes(nodeName2)) {50391 -1 out.push(el);50392 -1 }50393 -1 return out;50394 -1 }, []);50395 -1 this.relatedNodes(relatedNodes);50396 -1 if (relatedNodes.length && is_modal_open_default()) {50397 -1 return true;50398 -1 }50399 -1 return relatedNodes.length === 0;50400 -1 }50401 -1 var focusable_disabled_evaluate_default = focusableDisabledEvaluate;50402 -1 function focusableElementEvaluate(node, options, virtualNode) {50403 -1 if (virtualNode.hasAttr('contenteditable') && isContenteditable(virtualNode)) {50404 -1 return true;50405 -1 }50406 -1 var isFocusable2 = virtualNode.isFocusable;50407 -1 var tabIndex = parseInt(virtualNode.attr('tabindex'), 10);50408 -1 tabIndex = !isNaN(tabIndex) ? tabIndex : null;50409 -1 return tabIndex ? isFocusable2 && tabIndex >= 0 : isFocusable2;50410 -1 function isContenteditable(vNode) {50411 -1 var contenteditable = vNode.attr('contenteditable');50412 -1 if (contenteditable === 'true' || contenteditable === '') {50413 -1 return true;50414 -1 }50415 -1 if (contenteditable === 'false') {50416 -1 return false;50417 -1 }50418 -1 var ancestor = closest_default(virtualNode.parent, '[contenteditable]');50419 -1 if (!ancestor) {50420 -1 return false;50421 -1 }50422 -1 return isContenteditable(ancestor);50423 -1 }50424 -1 }50425 -1 var focusable_element_evaluate_default = focusableElementEvaluate;50426 -1 function focusableModalOpenEvaluate(node, options, virtualNode) {50427 -1 var tabbableElements = virtualNode.tabbableElements.map(function(_ref67) {50428 -1 var actualNode = _ref67.actualNode;50429 -1 return actualNode;50430 -1 });50431 -1 if (!tabbableElements || !tabbableElements.length) {50432 -1 return true;50433 -1 }50434 -1 if (is_modal_open_default()) {50435 -1 this.relatedNodes(tabbableElements);50436 -1 return void 0;50437 -1 }50438 -1 return true;-1 25112 function ariaLabelEvaluate(node, options, virtualNode) { -1 25113 return !!sanitize_default(arialabel_text_default(virtualNode)); 50439 25114 }50440 -1 var focusable_modal_open_evaluate_default = focusableModalOpenEvaluate;50441 -1 function focusableNoNameEvaluate(node, options, virtualNode) {50442 -1 var tabIndex = virtualNode.attr('tabindex');50443 -1 var inFocusOrder = is_focusable_default(virtualNode) && tabIndex > -1;50444 -1 if (!inFocusOrder) {50445 -1 return false;50446 -1 }-1 25115 var aria_label_evaluate_default = ariaLabelEvaluate; -1 25116 function ariaLabelledbyEvaluate(node, options, virtualNode) { 50447 25117 try {50448 -1 return !accessible_text_virtual_default(virtualNode);-1 25118 return !!sanitize_default(arialabelledby_text_default(virtualNode)); 50449 25119 } catch (e) { 50450 25120 return void 0; 50451 25121 } 50452 25122 }50453 -1 var focusable_no_name_evaluate_default = focusableNoNameEvaluate;50454 -1 function focusableNotTabbableEvaluate(node, options, virtualNode) {50455 -1 var elementsThatCanBeDisabled = [ 'BUTTON', 'FIELDSET', 'INPUT', 'SELECT', 'TEXTAREA' ];50456 -1 var tabbableElements = virtualNode.tabbableElements;50457 -1 if (!tabbableElements || !tabbableElements.length) {50458 -1 return true;50459 -1 }50460 -1 var relatedNodes = tabbableElements.reduce(function(out, _ref68) {50461 -1 var el = _ref68.actualNode;50462 -1 var nodeName2 = el.nodeName.toUpperCase();50463 -1 if (!elementsThatCanBeDisabled.includes(nodeName2)) {50464 -1 out.push(el);50465 -1 }50466 -1 return out;50467 -1 }, []);50468 -1 this.relatedNodes(relatedNodes);50469 -1 if (relatedNodes.length > 0 && is_modal_open_default()) {50470 -1 return true;50471 -1 }50472 -1 return relatedNodes.length === 0;50473 -1 }50474 -1 var focusable_not_tabbable_evaluate_default = focusableNotTabbableEvaluate;50475 -1 function landmarkIsTopLevelEvaluate(node) {50476 -1 var landmarks = get_aria_roles_by_type_default('landmark');50477 -1 var parent = get_composed_parent_default(node);50478 -1 var nodeRole = get_role_default(node);50479 -1 this.data({50480 -1 role: nodeRole50481 -1 });50482 -1 while (parent) {50483 -1 var role = parent.getAttribute('role');50484 -1 if (!role && parent.nodeName.toUpperCase() !== 'FORM') {50485 -1 role = implicit_role_default(parent);50486 -1 }50487 -1 if (role && landmarks.includes(role) && !(role === 'main' && nodeRole === 'complementary')) {50488 -1 return false;50489 -1 }50490 -1 parent = get_composed_parent_default(parent);50491 -1 }50492 -1 return true;50493 -1 }50494 -1 var landmark_is_top_level_evaluate_default = landmarkIsTopLevelEvaluate;50495 -1 function focusableDescendants(vNode) {50496 -1 if (is_focusable_default(vNode)) {50497 -1 return true;50498 -1 }50499 -1 if (!vNode.children) {50500 -1 if (vNode.props.nodeType === 1) {50501 -1 throw new Error('Cannot determine children');-1 25123 var aria_labelledby_evaluate_default = ariaLabelledbyEvaluate; -1 25124 function avoidInlineSpacingEvaluate(node, options) { -1 25125 var overriddenProperties = options.cssProperties.filter(function(property) { -1 25126 if (node.style.getPropertyPriority(property) === 'important') { -1 25127 return property; 50502 25128 }50503 -1 return false;50504 -1 }50505 -1 return vNode.children.some(function(child) {50506 -1 return focusableDescendants(child);50507 25129 });50508 -1 }50509 -1 function noFocusbleContentEvaluate(node, options, virtualNode) {50510 -1 if (!virtualNode.children) {50511 -1 return void 0;50512 -1 }50513 -1 try {50514 -1 return !virtualNode.children.some(function(child) {50515 -1 return focusableDescendants(child);50516 -1 });50517 -1 } catch (e) {50518 -1 return void 0;50519 -1 }50520 -1 }50521 -1 var no_focusable_content_evaluate_default = noFocusbleContentEvaluate;50522 -1 function tabindexEvaluate(node, options, virtualNode) {50523 -1 var tabIndex = parseInt(virtualNode.attr('tabindex'), 10);50524 -1 return isNaN(tabIndex) ? true : tabIndex <= 0;50525 -1 }50526 -1 var tabindex_evaluate_default = tabindexEvaluate;50527 -1 function altSpaceValueEvaluate(node, options, virtualNode) {50528 -1 var alt = virtualNode.attr('alt');50529 -1 var isOnlySpace = /^\s+$/;50530 -1 return typeof alt === 'string' && isOnlySpace.test(alt);50531 -1 }50532 -1 var alt_space_value_evaluate_default = altSpaceValueEvaluate;50533 -1 function duplicateImgLabelEvaluate(node, options, virtualNode) {50534 -1 if ([ 'none', 'presentation' ].includes(get_role_default(virtualNode))) {50535 -1 return false;50536 -1 }50537 -1 var parentVNode = closest_default(virtualNode, options.parentSelector);50538 -1 if (!parentVNode) {50539 -1 return false;50540 -1 }50541 -1 var visibleText = visible_virtual_default(parentVNode, true).toLowerCase();50542 -1 if (visibleText === '') {50543 -1 return false;50544 -1 }50545 -1 return visibleText === accessible_text_virtual_default(virtualNode).toLowerCase();50546 -1 }50547 -1 var duplicate_img_label_evaluate_default = duplicateImgLabelEvaluate;50548 -1 function explicitEvaluate(node, options, virtualNode) {50549 -1 if (virtualNode.attr('id')) {50550 -1 if (!virtualNode.actualNode) {50551 -1 return void 0;50552 -1 }50553 -1 var root = get_root_node_default2(virtualNode.actualNode);50554 -1 var id = escape_selector_default(virtualNode.attr('id'));50555 -1 var labels = Array.from(root.querySelectorAll('label[for="'.concat(id, '"]')));50556 -1 if (labels.length) {50557 -1 try {50558 -1 return labels.some(function(label5) {50559 -1 if (!is_visible_default(label5)) {50560 -1 return true;50561 -1 } else {50562 -1 return !!accessible_text_default(label5);50563 -1 }50564 -1 });50565 -1 } catch (e) {50566 -1 return void 0;50567 -1 }50568 -1 }50569 -1 }50570 -1 return false;50571 -1 }50572 -1 var explicit_evaluate_default = explicitEvaluate;50573 -1 function helpSameAsLabelEvaluate(node, options, virtualNode) {50574 -1 var labelText2 = label_virtual_default2(virtualNode), check4 = node.getAttribute('title');50575 -1 if (!labelText2) {-1 25130 if (overriddenProperties.length > 0) { -1 25131 this.data(overriddenProperties); 50576 25132 return false; 50577 25133 }50578 -1 if (!check4) {50579 -1 check4 = '';50580 -1 if (node.getAttribute('aria-describedby')) {50581 -1 var ref = idrefs_default(node, 'aria-describedby');50582 -1 check4 = ref.map(function(thing) {50583 -1 return thing ? accessible_text_default(thing) : '';50584 -1 }).join('');50585 -1 }50586 -1 }50587 -1 return sanitize_default(check4) === sanitize_default(labelText2);-1 25134 return true; 50588 25135 }50589 -1 var help_same_as_label_evaluate_default = helpSameAsLabelEvaluate;50590 -1 function hiddenExplicitLabelEvaluate(node, options, virtualNode) {50591 -1 if (virtualNode.hasAttr('id')) {50592 -1 if (!virtualNode.actualNode) {50593 -1 return void 0;50594 -1 }50595 -1 var root = get_root_node_default2(node);50596 -1 var id = escape_selector_default(node.getAttribute('id'));50597 -1 var label5 = root.querySelector('label[for="'.concat(id, '"]'));50598 -1 if (label5 && !is_visible_default(label5, true)) {50599 -1 var name;50600 -1 try {50601 -1 name = accessible_text_virtual_default(virtualNode).trim();50602 -1 } catch (e) {50603 -1 return void 0;50604 -1 }50605 -1 var isNameEmpty = name === '';50606 -1 return isNameEmpty;50607 -1 }50608 -1 }50609 -1 return false;-1 25136 var avoid_inline_spacing_evaluate_default = avoidInlineSpacingEvaluate; -1 25137 function docHasTitleEvaluate() { -1 25138 var title = document.title; -1 25139 return !!sanitize_default(title); 50610 25140 }50611 -1 var hidden_explicit_label_evaluate_default = hiddenExplicitLabelEvaluate;50612 -1 function implicitEvaluate(node, options, virtualNode) {50613 -1 try {50614 -1 var label5 = closest_default(virtualNode, 'label');50615 -1 if (label5) {50616 -1 return !!accessible_text_virtual_default(label5, {50617 -1 inControlContext: true50618 -1 });50619 -1 }50620 -1 return false;50621 -1 } catch (e) {50622 -1 return void 0;50623 -1 }-1 25141 var doc_has_title_evaluate_default = docHasTitleEvaluate; -1 25142 function existsEvaluate() { -1 25143 return void 0; 50624 25144 }50625 -1 var implicit_evaluate_default = implicitEvaluate;50626 -1 function isStringContained(compare, compareWith) {50627 -1 var curatedCompareWith = curateString(compareWith);50628 -1 var curatedCompare = curateString(compare);50629 -1 if (!curatedCompareWith || !curatedCompare) {-1 25145 var exists_evaluate_default = existsEvaluate; -1 25146 function hasAltEvaluate(node, options, virtualNode) { -1 25147 var nodeName2 = virtualNode.props.nodeName; -1 25148 if (![ 'img', 'input', 'area' ].includes(nodeName2)) { 50630 25149 return false; 50631 25150 }50632 -1 return curatedCompareWith.includes(curatedCompare);50633 -1 }50634 -1 function curateString(str) {50635 -1 var noUnicodeStr = remove_unicode_default(str, {50636 -1 emoji: true,50637 -1 nonBmp: true,50638 -1 punctuations: true50639 -1 });50640 -1 return sanitize_default(noUnicodeStr);-1 25151 return virtualNode.hasAttr('alt'); 50641 25152 }50642 -1 function labelContentNameMismatchEvaluate(node, options, virtualNode) {50643 -1 var _ref69 = options || {}, pixelThreshold = _ref69.pixelThreshold, occuranceThreshold = _ref69.occuranceThreshold;50644 -1 var accText = accessible_text_default(node).toLowerCase();50645 -1 if (is_human_interpretable_default(accText) < 1) {50646 -1 return void 0;50647 -1 }50648 -1 var textVNodes = visible_text_nodes_default(virtualNode);50649 -1 var nonLigatureText = textVNodes.filter(function(textVNode) {50650 -1 return !is_icon_ligature_default(textVNode, pixelThreshold, occuranceThreshold);50651 -1 }).map(function(textVNode) {50652 -1 return textVNode.actualNode.nodeValue;50653 -1 }).join('');50654 -1 var visibleText = sanitize_default(nonLigatureText).toLowerCase();50655 -1 if (!visibleText) {50656 -1 return true;50657 -1 }50658 -1 if (is_human_interpretable_default(visibleText) < 1) {50659 -1 if (isStringContained(visibleText, accText)) {50660 -1 return true;50661 -1 }50662 -1 return void 0;50663 -1 }50664 -1 return isStringContained(visibleText, accText);-1 25153 var has_alt_evaluate_default = hasAltEvaluate; -1 25154 function isOnScreenEvaluate(node) { -1 25155 return is_visible_default(node, false) && !is_offscreen_default(node); 50665 25156 }50666 -1 var label_content_name_mismatch_evaluate_default = labelContentNameMismatchEvaluate;50667 -1 function multipleLabelEvaluate(node) {50668 -1 var id = escape_selector_default(node.getAttribute('id'));50669 -1 var parent = node.parentNode;50670 -1 var root = get_root_node_default2(node);50671 -1 root = root.documentElement || root;50672 -1 var labels = Array.from(root.querySelectorAll('label[for="'.concat(id, '"]')));50673 -1 if (labels.length) {50674 -1 labels = labels.filter(function(label5) {50675 -1 return is_visible_default(label5);-1 25157 var is_on_screen_evaluate_default = isOnScreenEvaluate; -1 25158 function nonEmptyIfPresentEvaluate(node, options, virtualNode) { -1 25159 var nodeName2 = virtualNode.props.nodeName; -1 25160 var type = (virtualNode.attr('type') || '').toLowerCase(); -1 25161 var label5 = virtualNode.attr('value'); -1 25162 if (label5) { -1 25163 this.data({ -1 25164 messageKey: 'has-label' 50676 25165 }); 50677 25166 }50678 -1 while (parent) {50679 -1 if (parent.nodeName.toUpperCase() === 'LABEL' && labels.indexOf(parent) === -1) {50680 -1 labels.push(parent);50681 -1 }50682 -1 parent = parent.parentNode;50683 -1 }50684 -1 this.relatedNodes(labels);50685 -1 if (labels.length > 1) {50686 -1 var ATVisibleLabels = labels.filter(function(label5) {50687 -1 return is_visible_default(label5, true);50688 -1 });50689 -1 if (ATVisibleLabels.length > 1) {50690 -1 return void 0;50691 -1 }50692 -1 var labelledby = idrefs_default(node, 'aria-labelledby');50693 -1 return !labelledby.includes(ATVisibleLabels[0]) ? void 0 : false;-1 25167 if (nodeName2 === 'input' && [ 'submit', 'reset' ].includes(type)) { -1 25168 return label5 === null; 50694 25169 } 50695 25170 return false; 50696 25171 }50697 -1 var multiple_label_evaluate_default = multipleLabelEvaluate;50698 -1 function titleOnlyEvaluate(node, options, virtualNode) {50699 -1 var labelText2 = label_virtual_default2(virtualNode);50700 -1 var title = title_text_default(virtualNode);50701 -1 var ariaDescribedBy = virtualNode.attr('aria-describedby');50702 -1 return !labelText2 && !!(title || ariaDescribedBy);50703 -1 }50704 -1 var title_only_evaluate_default = titleOnlyEvaluate;50705 -1 function landmarkIsUniqueAfter(results) {50706 -1 var uniqueLandmarks = [];50707 -1 return results.filter(function(currentResult) {50708 -1 var findMatch = function findMatch(someResult) {50709 -1 return currentResult.data.role === someResult.data.role && currentResult.data.accessibleText === someResult.data.accessibleText;50710 -1 };50711 -1 var matchedResult = uniqueLandmarks.find(findMatch);50712 -1 if (matchedResult) {50713 -1 matchedResult.result = false;50714 -1 matchedResult.relatedNodes.push(currentResult.relatedNodes[0]);50715 -1 return false;50716 -1 }50717 -1 uniqueLandmarks.push(currentResult);50718 -1 currentResult.relatedNodes = [];50719 -1 return true;50720 -1 });50721 -1 }50722 -1 var landmark_is_unique_after_default = landmarkIsUniqueAfter;50723 -1 function landmarkIsUniqueEvaluate(node, options, virtualNode) {50724 -1 var role = get_role_default(node);50725 -1 var accessibleText2 = accessible_text_virtual_default(virtualNode);50726 -1 accessibleText2 = accessibleText2 ? accessibleText2.toLowerCase() : null;50727 -1 this.data({50728 -1 role: role,50729 -1 accessibleText: accessibleText250730 -1 });50731 -1 this.relatedNodes([ node ]);50732 -1 return true;50733 -1 }50734 -1 var landmark_is_unique_evaluate_default = landmarkIsUniqueEvaluate;50735 -1 function hasValue(value) {50736 -1 return (value || '').trim() !== '';50737 -1 }50738 -1 function hasLangEvaluate(node, options, virtualNode) {50739 -1 var xhtml2 = typeof document !== 'undefined' ? is_xhtml_default(document) : false;50740 -1 if (options.attributes.includes('xml:lang') && options.attributes.includes('lang') && hasValue(virtualNode.attr('xml:lang')) && !hasValue(virtualNode.attr('lang')) && !xhtml2) {-1 25172 var non_empty_if_present_evaluate_default = nonEmptyIfPresentEvaluate; -1 25173 function presentationalRoleEvaluate(node, options, virtualNode) { -1 25174 var role = get_role_default(virtualNode); -1 25175 var explicitRole2 = get_explicit_role_default(virtualNode); -1 25176 if ([ 'presentation', 'none' ].includes(role)) { 50741 25177 this.data({50742 -1 messageKey: 'noXHTML'-1 25178 role: role 50743 25179 });50744 -1 return false;-1 25180 return true; 50745 25181 }50746 -1 var hasLang = options.attributes.some(function(name) {50747 -1 return hasValue(virtualNode.attr(name));50748 -1 });50749 -1 if (!hasLang) {50750 -1 this.data({50751 -1 messageKey: 'noLang'50752 -1 });-1 25182 if (![ 'presentation', 'none' ].includes(explicitRole2)) { 50753 25183 return false; 50754 25184 }50755 -1 return true;50756 -1 }50757 -1 var has_lang_evaluate_default = hasLangEvaluate;50758 -1 function validLangEvaluate(node, options, virtualNode) {50759 -1 var invalid = [];50760 -1 options.attributes.forEach(function(langAttr) {50761 -1 var langVal = virtualNode.attr(langAttr);50762 -1 if (typeof langVal !== 'string') {50763 -1 return;50764 -1 }50765 -1 var baselangVal = get_base_lang_default(langVal);50766 -1 var invalidLang = options.value ? !options.value.map(get_base_lang_default).includes(baselangVal) : !valid_langs_default(baselangVal);50767 -1 if (baselangVal !== '' && invalidLang || langVal !== '' && !sanitize_default(langVal)) {50768 -1 invalid.push(langAttr + '="' + virtualNode.attr(langAttr) + '"');50769 -1 }-1 25185 var hasGlobalAria = get_global_aria_attrs_default().some(function(attr) { -1 25186 return virtualNode.hasAttr(attr); 50770 25187 });50771 -1 if (invalid.length) {50772 -1 this.data(invalid);50773 -1 return true;-1 25188 var focusable = is_focusable_default(virtualNode); -1 25189 var messageKey; -1 25190 if (hasGlobalAria && !focusable) { -1 25191 messageKey = 'globalAria'; -1 25192 } else if (!hasGlobalAria && focusable) { -1 25193 messageKey = 'focusable'; -1 25194 } else { -1 25195 messageKey = 'both'; 50774 25196 } -1 25197 this.data({ -1 25198 messageKey: messageKey, -1 25199 role: role -1 25200 }); 50775 25201 return false; 50776 25202 }50777 -1 var valid_lang_evaluate_default = validLangEvaluate;50778 -1 function xmlLangMismatchEvaluate(node, options, vNode) {50779 -1 var primaryLangValue = get_base_lang_default(vNode.attr('lang'));50780 -1 var primaryXmlLangValue = get_base_lang_default(vNode.attr('xml:lang'));50781 -1 return primaryLangValue === primaryXmlLangValue;50782 -1 }50783 -1 var xml_lang_mismatch_evaluate_default = xmlLangMismatchEvaluate;50784 -1 function dlitemEvaluate(node) {50785 -1 var parent = get_composed_parent_default(node);50786 -1 var parentTagName = parent.nodeName.toUpperCase();50787 -1 var parentRole = get_explicit_role_default(parent);50788 -1 if (parentTagName === 'DIV' && [ 'presentation', 'none', null ].includes(parentRole)) {50789 -1 parent = get_composed_parent_default(parent);50790 -1 parentTagName = parent.nodeName.toUpperCase();50791 -1 parentRole = get_explicit_role_default(parent);-1 25203 var presentational_role_evaluate_default = presentationalRoleEvaluate; -1 25204 function svgNonEmptyTitleEvaluate(node, options, virtualNode) { -1 25205 if (!virtualNode.children) { -1 25206 return void 0; 50792 25207 }50793 -1 if (parentTagName !== 'DL') {-1 25208 var titleNode = virtualNode.children.find(function(_ref84) { -1 25209 var props = _ref84.props; -1 25210 return props.nodeName === 'title'; -1 25211 }); -1 25212 if (!titleNode) { -1 25213 this.data({ -1 25214 messageKey: 'noTitle' -1 25215 }); 50794 25216 return false; 50795 25217 }50796 -1 if (!parentRole || [ 'presentation', 'none', 'list' ].includes(parentRole)) {50797 -1 return true;50798 -1 }50799 -1 return false;50800 -1 }50801 -1 var dlitem_evaluate_default = dlitemEvaluate;50802 -1 function listitemEvaluate(node) {50803 -1 var parent = get_composed_parent_default(node);50804 -1 if (!parent) {-1 25218 try { -1 25219 if (visible_virtual_default(titleNode) === '') { -1 25220 this.data({ -1 25221 messageKey: 'emptyTitle' -1 25222 }); -1 25223 return false; -1 25224 } -1 25225 } catch (e) { 50805 25226 return void 0; 50806 25227 }50807 -1 var parentTagName = parent.nodeName.toUpperCase();50808 -1 var parentRole = (parent.getAttribute('role') || '').toLowerCase();50809 -1 if ([ 'presentation', 'none', 'list' ].includes(parentRole)) {-1 25228 return true; -1 25229 } -1 25230 var svg_non_empty_title_evaluate_default = svgNonEmptyTitleEvaluate; -1 25231 function captionFakedEvaluate(node) { -1 25232 var table5 = to_grid_default(node); -1 25233 var firstRow = table5[0]; -1 25234 if (table5.length <= 1 || firstRow.length <= 1 || node.rows.length <= 1) { 50810 25235 return true; 50811 25236 }50812 -1 if (parentRole && is_valid_role_default(parentRole)) {50813 -1 this.data({50814 -1 messageKey: 'roleNotValid'50815 -1 });50816 -1 return false;-1 25237 return firstRow.reduce(function(out, curr, i) { -1 25238 return out || curr !== firstRow[i + 1] && firstRow[i + 1] !== void 0; -1 25239 }, false); -1 25240 } -1 25241 var caption_faked_evaluate_default = captionFakedEvaluate; -1 25242 function html5ScopeEvaluate(node) { -1 25243 if (!is_html5_default(document)) { -1 25244 return true; 50817 25245 }50818 -1 return [ 'UL', 'OL' ].includes(parentTagName);-1 25246 return node.nodeName.toUpperCase() === 'TH'; 50819 25247 }50820 -1 var listitem_evaluate_default = listitemEvaluate;50821 -1 function onlyDlitemsEvaluate(node, options, virtualNode) {50822 -1 var ALLOWED_ROLES = [ 'definition', 'term', 'list' ];50823 -1 var base = {50824 -1 badNodes: [],50825 -1 hasNonEmptyTextNode: false50826 -1 };50827 -1 var content = virtualNode.children.reduce(function(content2, child) {50828 -1 var actualNode = child.actualNode;50829 -1 if (actualNode.nodeName.toUpperCase() === 'DIV' && get_role_default(actualNode) === null) {50830 -1 return content2.concat(child.children);50831 -1 }50832 -1 return content2.concat(child);50833 -1 }, []);50834 -1 var result = content.reduce(function(out, childNode) {50835 -1 var actualNode = childNode.actualNode;50836 -1 var tagName = actualNode.nodeName.toUpperCase();50837 -1 if (actualNode.nodeType === 1 && is_visible_default(actualNode, true, false)) {50838 -1 var explicitRole2 = get_explicit_role_default(actualNode);50839 -1 if (tagName !== 'DT' && tagName !== 'DD' || explicitRole2) {50840 -1 if (!ALLOWED_ROLES.includes(explicitRole2)) {50841 -1 out.badNodes.push(actualNode);50842 -1 }-1 25248 var html5_scope_evaluate_default = html5ScopeEvaluate; -1 25249 function sameCaptionSummaryEvaluate(node) { -1 25250 return !!(node.summary && node.caption) && node.summary.toLowerCase() === accessible_text_default(node.caption).toLowerCase(); -1 25251 } -1 25252 var same_caption_summary_evaluate_default = sameCaptionSummaryEvaluate; -1 25253 function scopeValueEvaluate(node, options) { -1 25254 var value = node.getAttribute('scope').toLowerCase(); -1 25255 return options.values.indexOf(value) !== -1; -1 25256 } -1 25257 var scope_value_evaluate_default = scopeValueEvaluate; -1 25258 function tdHasHeaderEvaluate(node) { -1 25259 var badCells = []; -1 25260 var cells = get_all_cells_default(node); -1 25261 var tableGrid = to_grid_default(node); -1 25262 cells.forEach(function(cell) { -1 25263 if (has_content_default(cell) && is_data_cell_default(cell) && !label_default2(cell)) { -1 25264 var hasHeaders = get_headers_default(cell, tableGrid).some(function(header) { -1 25265 return header !== null && !!has_content_default(header); -1 25266 }); -1 25267 if (!hasHeaders) { -1 25268 badCells.push(cell); 50843 25269 }50844 -1 } else if (actualNode.nodeType === 3 && actualNode.nodeValue.trim() !== '') {50845 -1 out.hasNonEmptyTextNode = true;50846 25270 }50847 -1 return out;50848 -1 }, base);50849 -1 if (result.badNodes.length) {50850 -1 this.relatedNodes(result.badNodes);-1 25271 }); -1 25272 if (badCells.length) { -1 25273 this.relatedNodes(badCells); -1 25274 return false; 50851 25275 }50852 -1 return !!result.badNodes.length || result.hasNonEmptyTextNode;-1 25276 return true; 50853 25277 }50854 -1 var only_dlitems_evaluate_default = onlyDlitemsEvaluate;50855 -1 function onlyListitemsEvaluate(node, options, virtualNode) {50856 -1 var hasNonEmptyTextNode = false;50857 -1 var atLeastOneListitem = false;50858 -1 var isEmpty = true;50859 -1 var badNodes = [];50860 -1 var badRoleNodes = [];50861 -1 var badRoles = [];50862 -1 virtualNode.children.forEach(function(vNode) {50863 -1 var actualNode = vNode.actualNode;50864 -1 if (actualNode.nodeType === 3 && actualNode.nodeValue.trim() !== '') {50865 -1 hasNonEmptyTextNode = true;50866 -1 return;-1 25278 var td_has_header_evaluate_default = tdHasHeaderEvaluate; -1 25279 function tdHeadersAttrEvaluate(node) { -1 25280 var cells = []; -1 25281 var reviewCells = []; -1 25282 var badCells = []; -1 25283 for (var rowIndex = 0; rowIndex < node.rows.length; rowIndex++) { -1 25284 var row = node.rows[rowIndex]; -1 25285 for (var cellIndex = 0; cellIndex < row.cells.length; cellIndex++) { -1 25286 cells.push(row.cells[cellIndex]); 50867 25287 }50868 -1 if (actualNode.nodeType !== 1 || !is_visible_default(actualNode, true, false)) {-1 25288 } -1 25289 var ids = cells.reduce(function(ids2, cell) { -1 25290 if (cell.getAttribute('id')) { -1 25291 ids2.push(cell.getAttribute('id')); -1 25292 } -1 25293 return ids2; -1 25294 }, []); -1 25295 cells.forEach(function(cell) { -1 25296 var isSelf = false; -1 25297 var notOfTable = false; -1 25298 if (!cell.hasAttribute('headers')) { 50869 25299 return; 50870 25300 }50871 -1 isEmpty = false;50872 -1 var isLi = actualNode.nodeName.toUpperCase() === 'LI';50873 -1 var role = get_role_default(vNode);50874 -1 var isListItemRole = role === 'listitem';50875 -1 if (!isLi && !isListItemRole) {50876 -1 badNodes.push(actualNode);-1 25301 var headersAttr = cell.getAttribute('headers').trim(); -1 25302 if (!headersAttr) { -1 25303 return reviewCells.push(cell); 50877 25304 }50878 -1 if (isLi && !isListItemRole) {50879 -1 badRoleNodes.push(actualNode);50880 -1 if (!badRoles.includes(role)) {50881 -1 badRoles.push(role);-1 25305 var headers = token_list_default(headersAttr); -1 25306 if (headers.length !== 0) { -1 25307 if (cell.getAttribute('id')) { -1 25308 isSelf = headers.indexOf(cell.getAttribute('id').trim()) !== -1; -1 25309 } -1 25310 notOfTable = headers.some(function(header) { -1 25311 return !ids.includes(header); -1 25312 }); -1 25313 if (isSelf || notOfTable) { -1 25314 badCells.push(cell); 50882 25315 }50883 -1 }50884 -1 if (isListItemRole) {50885 -1 atLeastOneListitem = true;50886 25316 } 50887 25317 });50888 -1 if (hasNonEmptyTextNode || badNodes.length) {50889 -1 this.relatedNodes(badNodes);50890 -1 return true;50891 -1 }50892 -1 if (isEmpty || atLeastOneListitem) {-1 25318 if (badCells.length > 0) { -1 25319 this.relatedNodes(badCells); 50893 25320 return false; 50894 25321 }50895 -1 this.relatedNodes(badRoleNodes);50896 -1 this.data({50897 -1 messageKey: 'roleNotValid',50898 -1 roles: badRoles.join(', ')50899 -1 });-1 25322 if (reviewCells.length) { -1 25323 this.relatedNodes(reviewCells); -1 25324 return void 0; -1 25325 } 50900 25326 return true; 50901 25327 }50902 -1 var only_listitems_evaluate_default = onlyListitemsEvaluate;50903 -1 function structuredDlitemsEvaluate(node, options, virtualNode) {50904 -1 var children = virtualNode.children;50905 -1 if (!children || !children.length) {50906 -1 return false;50907 -1 }50908 -1 var hasDt = false, hasDd = false, nodeName2;50909 -1 for (var i = 0; i < children.length; i++) {50910 -1 nodeName2 = children[i].props.nodeName.toUpperCase();50911 -1 if (nodeName2 === 'DT') {50912 -1 hasDt = true;50913 -1 }50914 -1 if (hasDt && nodeName2 === 'DD') {50915 -1 return false;-1 25328 var td_headers_attr_evaluate_default = tdHeadersAttrEvaluate; -1 25329 function thHasDataCellsEvaluate(node) { -1 25330 var cells = get_all_cells_default(node); -1 25331 var checkResult = this; -1 25332 var reffedHeaders = []; -1 25333 cells.forEach(function(cell) { -1 25334 var headers2 = cell.getAttribute('headers'); -1 25335 if (headers2) { -1 25336 reffedHeaders = reffedHeaders.concat(headers2.split(/\s+/)); 50916 25337 }50917 -1 if (nodeName2 === 'DD') {50918 -1 hasDd = true;-1 25338 var ariaLabel = cell.getAttribute('aria-labelledby'); -1 25339 if (ariaLabel) { -1 25340 reffedHeaders = reffedHeaders.concat(ariaLabel.split(/\s+/)); 50919 25341 }50920 -1 }50921 -1 return hasDt || hasDd;50922 -1 }50923 -1 var structured_dlitems_evaluate_default = structuredDlitemsEvaluate;50924 -1 function captionEvaluate(node, options, virtualNode) {50925 -1 var tracks = query_selector_all_default(virtualNode, 'track');50926 -1 var hasCaptions = tracks.some(function(vNode) {50927 -1 return (vNode.attr('kind') || '').toLowerCase() === 'captions';50928 25342 });50929 -1 return hasCaptions ? false : void 0;50930 -1 }50931 -1 var caption_evaluate_default = captionEvaluate;50932 -1 function frameTestedEvaluate(node, options) {50933 -1 return options.isViolation ? false : void 0;50934 -1 }50935 -1 var frame_tested_evaluate_default = frameTestedEvaluate;50936 -1 var joinStr = ' > ';50937 -1 function frameTestedAfter(results) {50938 -1 var iframes = {};50939 -1 return results.filter(function(result) {50940 -1 var frameResult = result.node.ancestry[result.node.ancestry.length - 1] !== 'html';50941 -1 if (frameResult) {50942 -1 var ancestry2 = result.node.ancestry.flat(Infinity).join(joinStr);50943 -1 iframes[ancestry2] = result;50944 -1 return true;50945 -1 }50946 -1 var ancestry = result.node.ancestry.slice(0, result.node.ancestry.length - 1).flat(Infinity).join(joinStr);50947 -1 if (iframes[ancestry]) {50948 -1 iframes[ancestry].result = true;-1 25343 var headers = cells.filter(function(cell) { -1 25344 if (sanitize_default(cell.textContent) === '') { -1 25345 return false; 50949 25346 }50950 -1 return false;-1 25347 return cell.nodeName.toUpperCase() === 'TH' || [ 'rowheader', 'columnheader' ].indexOf(cell.getAttribute('role')) !== -1; 50951 25348 });50952 -1 }50953 -1 var frame_tested_after_default = frameTestedAfter;50954 -1 function noAutoplayAudioEvaluate(node, options) {50955 -1 if (!node.duration) {50956 -1 console.warn('axe.utils.preloadMedia did not load metadata');50957 -1 return void 0;50958 -1 }50959 -1 var _options$allowedDurat = options.allowedDuration, allowedDuration = _options$allowedDurat === void 0 ? 3 : _options$allowedDurat;50960 -1 var playableDuration = getPlayableDuration(node);50961 -1 if (playableDuration <= allowedDuration && !node.hasAttribute('loop')) {50962 -1 return true;50963 -1 }50964 -1 if (!node.hasAttribute('controls')) {50965 -1 return false;50966 -1 }50967 -1 return true;50968 -1 function getPlayableDuration(elm) {50969 -1 if (!elm.currentSrc) {50970 -1 return 0;-1 25349 var tableGrid = to_grid_default(node); -1 25350 var out = true; -1 25351 headers.forEach(function(header) { -1 25352 if (header.getAttribute('id') && reffedHeaders.includes(header.getAttribute('id'))) { -1 25353 return; 50971 25354 }50972 -1 var playbackRange = getPlaybackRange(elm.currentSrc);50973 -1 if (!playbackRange) {50974 -1 return Math.abs(elm.duration - (elm.currentTime || 0));-1 25355 var pos = get_cell_position_default(header, tableGrid); -1 25356 var hasCell = false; -1 25357 if (is_column_header_default(header)) { -1 25358 hasCell = traverse_default('down', pos, tableGrid).find(function(cell) { -1 25359 return !is_column_header_default(cell) && get_headers_default(cell, tableGrid).includes(header); -1 25360 }); 50975 25361 }50976 -1 if (playbackRange.length === 1) {50977 -1 return Math.abs(elm.duration - playbackRange[0]);-1 25362 if (!hasCell && is_row_header_default(header)) { -1 25363 hasCell = traverse_default('right', pos, tableGrid).find(function(cell) { -1 25364 return !is_row_header_default(cell) && get_headers_default(cell, tableGrid).includes(header); -1 25365 }); 50978 25366 }50979 -1 return Math.abs(playbackRange[1] - playbackRange[0]);50980 -1 }50981 -1 function getPlaybackRange(src) {50982 -1 var match = src.match(/#t=(.*)/);50983 -1 if (!match) {50984 -1 return;-1 25367 if (!hasCell) { -1 25368 checkResult.relatedNodes(header); 50985 25369 }50986 -1 var _match = _slicedToArray(match, 2), value = _match[1];50987 -1 var ranges = value.split(',');50988 -1 return ranges.map(function(range) {50989 -1 if (/:/.test(range)) {50990 -1 return convertHourMinSecToSeconds(range);-1 25370 out = out && hasCell; -1 25371 }); -1 25372 return out ? true : void 0; -1 25373 } -1 25374 var th_has_data_cells_evaluate_default = thHasDataCellsEvaluate; -1 25375 function hiddenContentEvaluate(node, options, virtualNode) { -1 25376 var allowlist = [ 'SCRIPT', 'HEAD', 'TITLE', 'NOSCRIPT', 'STYLE', 'TEMPLATE' ]; -1 25377 if (!allowlist.includes(node.nodeName.toUpperCase()) && has_content_virtual_default(virtualNode)) { -1 25378 var styles = window.getComputedStyle(node); -1 25379 if (styles.getPropertyValue('display') === 'none') { -1 25380 return void 0; -1 25381 } else if (styles.getPropertyValue('visibility') === 'hidden') { -1 25382 var parent = get_composed_parent_default(node); -1 25383 var parentStyle = parent && window.getComputedStyle(parent); -1 25384 if (!parentStyle || parentStyle.getPropertyValue('visibility') !== 'hidden') { -1 25385 return void 0; 50991 25386 }50992 -1 return parseFloat(range);50993 -1 });50994 -1 }50995 -1 function convertHourMinSecToSeconds(hhMmSs) {50996 -1 var parts = hhMmSs.split(':');50997 -1 var secs = 0;50998 -1 var mins = 1;50999 -1 while (parts.length > 0) {51000 -1 secs += mins * parseInt(parts.pop(), 10);51001 -1 mins *= 60;51002 25387 }51003 -1 return parseFloat(secs);51004 25388 } -1 25389 return true; 51005 25390 }51006 -1 var no_autoplay_audio_evaluate_default = noAutoplayAudioEvaluate;-1 25391 var hidden_content_evaluate_default = hiddenContentEvaluate; 51007 25392 function ariaAllowedAttrMatches(node, virtualNode) {51008 -1 var aria44 = /^aria-/;-1 25393 var aria49 = /^aria-/; 51009 25394 var attrs = virtualNode.attrNames; 51010 25395 if (attrs.length) {51011 -1 for (var _i22 = 0, l = attrs.length; _i22 < l; _i22++) {51012 -1 if (aria44.test(attrs[_i22])) {-1 25396 for (var _i23 = 0, l = attrs.length; _i23 < l; _i23++) { -1 25397 if (aria49.test(attrs[_i23])) { 51013 25398 return true; 51014 25399 } 51015 25400 } @@ -51017,17 +25402,17 @@ module.exports = { 51017 25402 return false; 51018 25403 } 51019 25404 var aria_allowed_attr_matches_default = ariaAllowedAttrMatches;51020 -1 function ariaAllowedRoleMatches(node) {51021 -1 return get_explicit_role_default(node, {-1 25405 function ariaAllowedRoleMatches(node, virtualNode) { -1 25406 return get_explicit_role_default(virtualNode, { 51022 25407 dpub: true, 51023 25408 fallback: true 51024 25409 }) !== null; 51025 25410 } 51026 25411 var aria_allowed_role_matches_default = ariaAllowedRoleMatches; 51027 25412 function ariaHasAttrMatches(node, virtualNode) {51028 -1 var aria44 = /^aria-/;-1 25413 var aria49 = /^aria-/; 51029 25414 return virtualNode.attrNames.some(function(attr) {51030 -1 return aria44.test(attr);-1 25415 return aria49.test(attr); 51031 25416 }); 51032 25417 } 51033 25418 var aria_has_attr_matches_default = ariaHasAttrMatches; @@ -51087,12 +25472,12 @@ module.exports = { 51087 25472 return true; 51088 25473 } 51089 25474 var autocomplete_matches_default = autocompleteMatches;51090 -1 function isInitiatorMatches(node, virtualNode, context3) {51091 -1 return context3.initiator;-1 25475 function isInitiatorMatches(node, virtualNode, context5) { -1 25476 return context5.initiator; 51092 25477 } 51093 25478 var is_initiator_matches_default = isInitiatorMatches;51094 -1 function bypassMatches(node, virtualNode, context3) {51095 -1 if (is_initiator_matches_default(node, virtualNode, context3)) {-1 25479 function bypassMatches(node, virtualNode, context5) { -1 25480 if (is_initiator_matches_default(node, virtualNode, context5)) { 51096 25481 return !!node.querySelector('a[href]'); 51097 25482 } 51098 25483 return true; @@ -51223,8 +25608,9 @@ module.exports = { 51223 25608 }); 51224 25609 } 51225 25610 var duplicate_id_misc_matches_default = duplicateIdMiscMatches;51226 -1 function frameFocusableContentMatches(node, virtualNode, context3) {51227 -1 return !context3.initiator && !context3.focusable && context3.boundingClientRect.width * context3.boundingClientRect.height > 1;-1 25611 function frameFocusableContentMatches(node, virtualNode, context5) { -1 25612 var _context5$size, _context5$size2; -1 25613 return !context5.initiator && !context5.focusable && ((_context5$size = context5.size) === null || _context5$size === void 0 ? void 0 : _context5$size.width) * ((_context5$size2 = context5.size) === null || _context5$size2 === void 0 ? void 0 : _context5$size2.height) > 1; 51228 25614 } 51229 25615 var frame_focusable_content_matches_default = frameFocusableContentMatches; 51230 25616 function frameTitleHasTextMatches(node) { @@ -51232,6 +25618,12 @@ module.exports = { 51232 25618 return !!sanitize_default(title); 51233 25619 } 51234 25620 var frame_title_has_text_matches_default = frameTitleHasTextMatches; -1 25621 function hasImplicitChromiumRoleMatches(node, virtualNode) { -1 25622 return implicit_role_default(virtualNode, { -1 25623 chromium: true -1 25624 }) !== null; -1 25625 } -1 25626 var has_implicit_chromium_role_matches_default = hasImplicitChromiumRoleMatches; 51235 25627 function headingMatches(node) { 51236 25628 var explicitRoles; 51237 25629 if (node.hasAttribute('role')) { @@ -51319,7 +25711,7 @@ module.exports = { 51319 25711 } 51320 25712 function isLandmarkVirtual(virtualNode2) { 51321 25713 var actualNode = virtualNode2.actualNode;51322 -1 var landmarkRoles2 = get_aria_roles_by_type_default('landmark');-1 25714 var landmarkRoles3 = get_aria_roles_by_type_default('landmark'); 51323 25715 var role = get_role_default(actualNode); 51324 25716 if (!role) { 51325 25717 return false; @@ -51332,7 +25724,7 @@ module.exports = { 51332 25724 var accessibleText2 = accessible_text_virtual_default(virtualNode2); 51333 25725 return !!accessibleText2; 51334 25726 }51335 -1 return landmarkRoles2.indexOf(role) >= 0 || role === 'region';-1 25727 return landmarkRoles3.indexOf(role) >= 0 || role === 'region'; 51336 25728 } 51337 25729 return isLandmarkVirtual(virtualNode) && is_visible_default(node, true); 51338 25730 } @@ -51389,7 +25781,7 @@ module.exports = { 51389 25781 if (!role || [ 'none', 'presentation' ].includes(role)) { 51390 25782 return true; 51391 25783 }51392 -1 var _ref70 = aria_roles_default[role] || {}, accessibleNameRequired = _ref70.accessibleNameRequired;-1 25784 var _ref85 = aria_roles_default[role] || {}, accessibleNameRequired = _ref85.accessibleNameRequired; 51393 25785 if (accessibleNameRequired || is_focusable_default(virtualNode)) { 51394 25786 return true; 51395 25787 } @@ -51428,12 +25820,18 @@ module.exports = { 51428 25820 return siblingsAfter.length !== 0; 51429 25821 } 51430 25822 var p_as_heading_matches_default = pAsHeadingMatches; -1 25823 function presentationRoleConflictMatches(node, virtualNode) { -1 25824 return implicit_role_default(virtualNode, { -1 25825 chromiumRoles: true -1 25826 }) !== null; -1 25827 } -1 25828 var presentation_role_conflict_matches_default = presentationRoleConflictMatches; 51431 25829 function scrollableRegionFocusableMatches(node, virtualNode) {51432 -1 if (!!get_scroll_default(node, 13) === false) {-1 25830 if (!!_getScroll(node, 13) === false) { 51433 25831 return false; 51434 25832 } 51435 25833 var role = get_explicit_role_default(virtualNode);51436 -1 if (standards_default.ariaRoles.combobox.requiredOwned.includes(role)) {-1 25834 if (aria_attrs_default['aria-haspopup'].values.includes(role)) { 51437 25835 if (closest_default(virtualNode, '[role~="combobox"]')) { 51438 25836 return false; 51439 25837 } @@ -51461,7 +25859,7 @@ module.exports = { 51461 25859 } 51462 25860 var scrollable_region_focusable_matches_default = scrollableRegionFocusableMatches; 51463 25861 function skipLinkMatches(node) {51464 -1 return is_skip_link_default(node) && is_offscreen_default(node);-1 25862 return _isSkipLink(node) && is_offscreen_default(node); 51465 25863 } 51466 25864 var skip_link_matches_default = skipLinkMatches; 51467 25865 function windowIsTopMatches(node) { @@ -51476,145 +25874,149 @@ module.exports = { 51476 25874 var xml_lang_mismatch_matches_default = xmlLangMismatchMatches; 51477 25875 var metadataFunctionMap = { 51478 25876 'abstractrole-evaluate': abstractrole_evaluate_default, -1 25877 'accesskeys-after': accesskeys_after_default, -1 25878 'accesskeys-evaluate': accesskeys_evaluate_default, -1 25879 'alt-space-value-evaluate': alt_space_value_evaluate_default, 51479 25880 'aria-allowed-attr-evaluate': aria_allowed_attr_evaluate_default, -1 25881 'aria-allowed-attr-matches': aria_allowed_attr_matches_default, 51480 25882 'aria-allowed-role-evaluate': aria_allowed_role_evaluate_default, -1 25883 'aria-allowed-role-matches': aria_allowed_role_matches_default, 51481 25884 'aria-errormessage-evaluate': aria_errormessage_evaluate_default, -1 25885 'aria-has-attr-matches': aria_has_attr_matches_default, 51482 25886 'aria-hidden-body-evaluate': aria_hidden_body_evaluate_default,51483 -1 'aria-prohibited-attr-evaluate': aria_prohibited_attr_evaluate_default,-1 25887 'aria-hidden-focus-matches': aria_hidden_focus_matches_default, -1 25888 'aria-label-evaluate': aria_label_evaluate_default, -1 25889 'aria-labelledby-evaluate': aria_labelledby_evaluate_default, -1 25890 'aria-level-evaluate': aria_level_evaluate_default, -1 25891 'aria-prohibited-attr-evaluate': ariaProhibitedAttrEvaluate, 51484 25892 'aria-required-attr-evaluate': aria_required_attr_evaluate_default, 51485 25893 'aria-required-children-evaluate': aria_required_children_evaluate_default, -1 25894 'aria-required-children-matches': aria_required_children_matches_default, 51486 25895 'aria-required-parent-evaluate': aria_required_parent_evaluate_default, -1 25896 'aria-required-parent-matches': aria_required_parent_matches_default, 51487 25897 'aria-roledescription-evaluate': aria_roledescription_evaluate_default, 51488 25898 'aria-unsupported-attr-evaluate': aria_unsupported_attr_evaluate_default, 51489 25899 'aria-valid-attr-evaluate': aria_valid_attr_evaluate_default, 51490 25900 'aria-valid-attr-value-evaluate': aria_valid_attr_value_evaluate_default,51491 -1 'fallbackrole-evaluate': fallbackrole_evaluate_default,51492 -1 'has-global-aria-attribute-evaluate': has_global_aria_attribute_evaluate_default,51493 -1 'has-implicit-chromium-role-matches': has_implicit_chromium_role_matches_default,51494 -1 'has-widget-role-evaluate': has_widget_role_evaluate_default,51495 -1 'invalidrole-evaluate': invalidrole_evaluate_default,51496 -1 'is-element-focusable-evaluate': is_element_focusable_evaluate_default,51497 -1 'no-implicit-explicit-label-evaluate': no_implicit_explicit_label_evaluate_default,51498 -1 'unsupportedrole-evaluate': unsupportedrole_evaluate_default,51499 -1 'valid-scrollable-semantics-evaluate': valid_scrollable_semantics_evaluate_default,51500 -1 'caption-faked-evaluate': caption_faked_evaluate_default,51501 -1 'html5-scope-evaluate': html5_scope_evaluate_default,51502 -1 'same-caption-summary-evaluate': same_caption_summary_evaluate_default,51503 -1 'scope-value-evaluate': scope_value_evaluate_default,51504 -1 'td-has-header-evaluate': td_has_header_evaluate_default,51505 -1 'td-headers-attr-evaluate': td_headers_attr_evaluate_default,51506 -1 'th-has-data-cells-evaluate': th_has_data_cells_evaluate_default,51507 -1 'hidden-content-evaluate': hidden_content_evaluate_default,51508 -1 'color-contrast-evaluate': color_contrast_evaluate_default,51509 -1 'link-in-text-block-evaluate': link_in_text_block_evaluate_default,-1 25901 'attr-non-space-content-evaluate': attr_non_space_content_evaluate_default, 51510 25902 'autocomplete-appropriate-evaluate': autocomplete_appropriate_evaluate_default, -1 25903 'autocomplete-matches': autocomplete_matches_default, 51511 25904 'autocomplete-valid-evaluate': autocomplete_valid_evaluate_default,51512 -1 'attr-non-space-content-evaluate': attr_non_space_content_evaluate_default,51513 -1 'has-descendant-after': has_descendant_after_default,51514 -1 'has-descendant-evaluate': has_descendant_evaluate_default,51515 -1 'has-text-content-evaluate': has_text_content_evaluate_default,51516 -1 'matches-definition-evaluate': matches_definition_evaluate_default,51517 -1 'page-no-duplicate-after': page_no_duplicate_after_default,51518 -1 'page-no-duplicate-evaluate': page_no_duplicate_evaluate_default,51519 -1 'heading-order-after': headingOrderAfter,51520 -1 'heading-order-evaluate': heading_order_evaluate_default,51521 -1 'identical-links-same-purpose-after': identical_links_same_purpose_after_default,51522 -1 'identical-links-same-purpose-evaluate': identical_links_same_purpose_evaluate_default,51523 -1 'internal-link-present-evaluate': internal_link_present_evaluate_default,51524 -1 'meta-refresh-evaluate': meta_refresh_evaluate_default,51525 -1 'p-as-heading-evaluate': p_as_heading_evaluate_default,51526 -1 'region-evaluate': region_evaluate_default,51527 -1 'skip-link-evaluate': skip_link_evaluate_default,51528 -1 'unique-frame-title-after': unique_frame_title_after_default,51529 -1 'unique-frame-title-evaluate': unique_frame_title_evaluate_default,51530 -1 'aria-label-evaluate': aria_label_evaluate_default,51531 -1 'aria-labelledby-evaluate': aria_labelledby_evaluate_default,51532 25905 'avoid-inline-spacing-evaluate': avoid_inline_spacing_evaluate_default,51533 -1 'doc-has-title-evaluate': doc_has_title_evaluate_default,51534 -1 'exists-evaluate': exists_evaluate_default,51535 -1 'has-alt-evaluate': has_alt_evaluate_default,51536 -1 'is-on-screen-evaluate': is_on_screen_evaluate_default,51537 -1 'non-empty-if-present-evaluate': non_empty_if_present_evaluate_default,51538 -1 'presentational-role-evaluate': presentational_role_evaluate_default,51539 -1 'svg-non-empty-title-evaluate': svg_non_empty_title_evaluate_default,-1 25906 'bypass-matches': bypass_matches_default, -1 25907 'caption-evaluate': caption_evaluate_default, -1 25908 'caption-faked-evaluate': caption_faked_evaluate_default, -1 25909 'color-contrast-evaluate': colorContrastEvaluate, -1 25910 'color-contrast-matches': color_contrast_matches_default, 51540 25911 'css-orientation-lock-evaluate': css_orientation_lock_evaluate_default,51541 -1 'meta-viewport-scale-evaluate': meta_viewport_scale_evaluate_default,-1 25912 'data-table-large-matches': data_table_large_matches_default, -1 25913 'data-table-matches': data_table_matches_default, -1 25914 'deprecatedrole-evaluate': deprecatedroleEvaluate, -1 25915 'dlitem-evaluate': dlitem_evaluate_default, -1 25916 'doc-has-title-evaluate': doc_has_title_evaluate_default, -1 25917 'duplicate-id-active-matches': duplicate_id_active_matches_default, 51542 25918 'duplicate-id-after': duplicate_id_after_default, -1 25919 'duplicate-id-aria-matches': duplicate_id_aria_matches_default, 51543 25920 'duplicate-id-evaluate': duplicate_id_evaluate_default,51544 -1 'accesskeys-after': accesskeys_after_default,51545 -1 'accesskeys-evaluate': accesskeys_evaluate_default,-1 25921 'duplicate-id-misc-matches': duplicate_id_misc_matches_default, -1 25922 'duplicate-img-label-evaluate': duplicate_img_label_evaluate_default, -1 25923 'exists-evaluate': exists_evaluate_default, -1 25924 'explicit-evaluate': explicit_evaluate_default, -1 25925 'fallbackrole-evaluate': fallbackrole_evaluate_default, 51546 25926 'focusable-content-evaluate': focusable_content_evaluate_default, 51547 25927 'focusable-disabled-evaluate': focusable_disabled_evaluate_default, 51548 25928 'focusable-element-evaluate': focusable_element_evaluate_default, 51549 25929 'focusable-modal-open-evaluate': focusable_modal_open_evaluate_default, 51550 25930 'focusable-no-name-evaluate': focusable_no_name_evaluate_default, 51551 25931 'focusable-not-tabbable-evaluate': focusable_not_tabbable_evaluate_default,51552 -1 'landmark-is-top-level-evaluate': landmark_is_top_level_evaluate_default,51553 -1 'no-focusable-content-evaluate': no_focusable_content_evaluate_default,51554 -1 'tabindex-evaluate': tabindex_evaluate_default,51555 -1 'alt-space-value-evaluate': alt_space_value_evaluate_default,51556 -1 'duplicate-img-label-evaluate': duplicate_img_label_evaluate_default,51557 -1 'explicit-evaluate': explicit_evaluate_default,51558 -1 'help-same-as-label-evaluate': help_same_as_label_evaluate_default,51559 -1 'hidden-explicit-label-evaluate': hidden_explicit_label_evaluate_default,51560 -1 'implicit-evaluate': implicit_evaluate_default,51561 -1 'label-content-name-mismatch-evaluate': label_content_name_mismatch_evaluate_default,51562 -1 'multiple-label-evaluate': multiple_label_evaluate_default,51563 -1 'title-only-evaluate': title_only_evaluate_default,51564 -1 'landmark-is-unique-after': landmark_is_unique_after_default,51565 -1 'landmark-is-unique-evaluate': landmark_is_unique_evaluate_default,51566 -1 'has-lang-evaluate': has_lang_evaluate_default,51567 -1 'valid-lang-evaluate': valid_lang_evaluate_default,51568 -1 'xml-lang-mismatch-evaluate': xml_lang_mismatch_evaluate_default,51569 -1 'dlitem-evaluate': dlitem_evaluate_default,51570 -1 'listitem-evaluate': listitem_evaluate_default,51571 -1 'only-dlitems-evaluate': only_dlitems_evaluate_default,51572 -1 'only-listitems-evaluate': only_listitems_evaluate_default,51573 -1 'structured-dlitems-evaluate': structured_dlitems_evaluate_default,51574 -1 'caption-evaluate': caption_evaluate_default,51575 -1 'frame-tested-evaluate': frame_tested_evaluate_default,51576 -1 'frame-tested-after': frame_tested_after_default,51577 -1 'no-autoplay-audio-evaluate': no_autoplay_audio_evaluate_default,51578 -1 'aria-allowed-attr-matches': aria_allowed_attr_matches_default,51579 -1 'aria-allowed-role-matches': aria_allowed_role_matches_default,51580 -1 'aria-form-field-name-matches': no_naming_method_matches_default,51581 -1 'aria-has-attr-matches': aria_has_attr_matches_default,51582 -1 'aria-hidden-focus-matches': aria_hidden_focus_matches_default,51583 -1 'aria-required-children-matches': aria_required_children_matches_default,51584 -1 'aria-required-parent-matches': aria_required_parent_matches_default,51585 -1 'autocomplete-matches': autocomplete_matches_default,51586 -1 'bypass-matches': bypass_matches_default,51587 -1 'color-contrast-matches': color_contrast_matches_default,51588 -1 'data-table-large-matches': data_table_large_matches_default,51589 -1 'data-table-matches': data_table_matches_default,51590 -1 'duplicate-id-active-matches': duplicate_id_active_matches_default,51591 -1 'duplicate-id-aria-matches': duplicate_id_aria_matches_default,51592 -1 'duplicate-id-misc-matches': duplicate_id_misc_matches_default,-1 25932 'frame-focusable-content-evaluate': frame_focusable_content_evaluate_default, 51593 25933 'frame-focusable-content-matches': frame_focusable_content_matches_default, -1 25934 'frame-tested-after': frame_tested_after_default, -1 25935 'frame-tested-evaluate': frame_tested_evaluate_default, 51594 25936 'frame-title-has-text-matches': frame_title_has_text_matches_default, -1 25937 'has-alt-evaluate': has_alt_evaluate_default, -1 25938 'has-descendant-after': has_descendant_after_default, -1 25939 'has-descendant-evaluate': has_descendant_evaluate_default, -1 25940 'has-global-aria-attribute-evaluate': has_global_aria_attribute_evaluate_default, -1 25941 'has-implicit-chromium-role-matches': has_implicit_chromium_role_matches_default, -1 25942 'has-lang-evaluate': has_lang_evaluate_default, -1 25943 'has-text-content-evaluate': has_text_content_evaluate_default, -1 25944 'has-widget-role-evaluate': has_widget_role_evaluate_default, 51595 25945 'heading-matches': heading_matches_default, -1 25946 'heading-order-after': headingOrderAfter, -1 25947 'heading-order-evaluate': heading_order_evaluate_default, -1 25948 'help-same-as-label-evaluate': help_same_as_label_evaluate_default, -1 25949 'hidden-content-evaluate': hidden_content_evaluate_default, -1 25950 'hidden-explicit-label-evaluate': hidden_explicit_label_evaluate_default, 51596 25951 'html-namespace-matches': html_namespace_matches_default, -1 25952 'html5-scope-evaluate': html5_scope_evaluate_default, -1 25953 'identical-links-same-purpose-after': identical_links_same_purpose_after_default, -1 25954 'identical-links-same-purpose-evaluate': identical_links_same_purpose_evaluate_default, 51597 25955 'identical-links-same-purpose-matches': identical_links_same_purpose_matches_default, -1 25956 'implicit-evaluate': implicit_evaluate_default, 51598 25957 'inserted-into-focus-order-matches': inserted_into_focus_order_matches_default, -1 25958 'internal-link-present-evaluate': internal_link_present_evaluate_default, -1 25959 'invalidrole-evaluate': invalidrole_evaluate_default, -1 25960 'is-element-focusable-evaluate': is_element_focusable_evaluate_default, 51599 25961 'is-initiator-matches': is_initiator_matches_default, -1 25962 'is-on-screen-evaluate': is_on_screen_evaluate_default, -1 25963 'label-content-name-mismatch-evaluate': label_content_name_mismatch_evaluate_default, 51600 25964 'label-content-name-mismatch-matches': label_content_name_mismatch_matches_default, 51601 25965 'label-matches': label_matches_default, 51602 25966 'landmark-has-body-context-matches': landmark_has_body_context_matches_default, -1 25967 'landmark-is-top-level-evaluate': landmark_is_top_level_evaluate_default, -1 25968 'landmark-is-unique-after': landmark_is_unique_after_default, -1 25969 'landmark-is-unique-evaluate': landmark_is_unique_evaluate_default, 51603 25970 'landmark-unique-matches': landmark_unique_matches_default, 51604 25971 'layout-table-matches': layout_table_matches_default, -1 25972 'link-in-text-block-evaluate': link_in_text_block_evaluate_default, 51605 25973 'link-in-text-block-matches': link_in_text_block_matches_default, -1 25974 'listitem-evaluate': listitemEvaluate, -1 25975 'matches-definition-evaluate': matches_definition_evaluate_default, -1 25976 'meta-refresh-evaluate': meta_refresh_evaluate_default, -1 25977 'meta-viewport-scale-evaluate': meta_viewport_scale_evaluate_default, -1 25978 'multiple-label-evaluate': multiple_label_evaluate_default, 51606 25979 'nested-interactive-matches': nested_interactive_matches_default, -1 25980 'no-autoplay-audio-evaluate': no_autoplay_audio_evaluate_default, 51607 25981 'no-autoplay-audio-matches': no_autoplay_audio_matches_default, 51608 25982 'no-empty-role-matches': no_empty_role_matches_default, 51609 25983 'no-explicit-name-required-matches': no_explicit_name_required_matches_default, -1 25984 'no-focusable-content-evaluate': noFocusableContentEvaluate, -1 25985 'no-implicit-explicit-label-evaluate': no_implicit_explicit_label_evaluate_default, 51610 25986 'no-naming-method-matches': no_naming_method_matches_default, 51611 25987 'no-role-matches': no_role_matches_default, -1 25988 'non-empty-if-present-evaluate': non_empty_if_present_evaluate_default, 51612 25989 'not-html-matches': not_html_matches_default, -1 25990 'only-dlitems-evaluate': only_dlitems_evaluate_default, -1 25991 'only-listitems-evaluate': only_listitems_evaluate_default, -1 25992 'p-as-heading-evaluate': p_as_heading_evaluate_default, 51613 25993 'p-as-heading-matches': p_as_heading_matches_default, -1 25994 'page-no-duplicate-after': page_no_duplicate_after_default, -1 25995 'page-no-duplicate-evaluate': page_no_duplicate_evaluate_default, -1 25996 'presentation-role-conflict-matches': presentation_role_conflict_matches_default, -1 25997 'presentational-role-evaluate': presentational_role_evaluate_default, -1 25998 'region-after': region_after_default, -1 25999 'region-evaluate': region_evaluate_default, -1 26000 'same-caption-summary-evaluate': same_caption_summary_evaluate_default, -1 26001 'scope-value-evaluate': scope_value_evaluate_default, 51614 26002 'scrollable-region-focusable-matches': scrollable_region_focusable_matches_default, -1 26003 'skip-link-evaluate': skip_link_evaluate_default, 51615 26004 'skip-link-matches': skip_link_matches_default, -1 26005 'structured-dlitems-evaluate': structured_dlitems_evaluate_default, 51616 26006 'svg-namespace-matches': svg_namespace_matches_default, -1 26007 'svg-non-empty-title-evaluate': svg_non_empty_title_evaluate_default, -1 26008 'tabindex-evaluate': tabindex_evaluate_default, -1 26009 'td-has-header-evaluate': td_has_header_evaluate_default, -1 26010 'td-headers-attr-evaluate': td_headers_attr_evaluate_default, -1 26011 'th-has-data-cells-evaluate': th_has_data_cells_evaluate_default, -1 26012 'title-only-evaluate': title_only_evaluate_default, -1 26013 'unique-frame-title-after': unique_frame_title_after_default, -1 26014 'unique-frame-title-evaluate': unique_frame_title_evaluate_default, -1 26015 'unsupportedrole-evaluate': unsupportedrole_evaluate_default, -1 26016 'valid-lang-evaluate': valid_lang_evaluate_default, -1 26017 'valid-scrollable-semantics-evaluate': valid_scrollable_semantics_evaluate_default, 51617 26018 'window-is-top-matches': window_is_top_matches_default, -1 26019 'xml-lang-mismatch-evaluate': xml_lang_mismatch_evaluate_default, 51618 26020 'xml-lang-mismatch-matches': xml_lang_mismatch_matches_default 51619 26021 }; 51620 26022 var metadata_function_map_default = metadataFunctionMap; @@ -51653,7 +26055,7 @@ module.exports = { 51653 26055 } 51654 26056 } 51655 26057 Check.prototype.enabled = true;51656 -1 Check.prototype.run = function run(node, options, context3, resolve, reject) {-1 26058 Check.prototype.run = function run(node, options, context5, resolve, reject) { 51657 26059 options = options || {}; 51658 26060 var enabled = options.hasOwnProperty('enabled') ? options.enabled : this.enabled; 51659 26061 var checkOptions = this.getOptions(options.options); @@ -51662,7 +26064,7 @@ module.exports = { 51662 26064 var helper = check_helper_default(checkResult, options, resolve, reject); 51663 26065 var result; 51664 26066 try {51665 -1 result = this.evaluate.call(helper, node.actualNode, checkOptions, node, context3);-1 26067 result = this.evaluate.call(helper, node.actualNode, checkOptions, node, context5); 51666 26068 } catch (e) { 51667 26069 if (node && node.actualNode) { 51668 26070 e.errorNode = new dq_element_default(node).toJSON(); @@ -51678,7 +26080,7 @@ module.exports = { 51678 26080 resolve(null); 51679 26081 } 51680 26082 };51681 -1 Check.prototype.runSync = function runSync(node, options, context3) {-1 26083 Check.prototype.runSync = function runSync(node, options, context5) { 51682 26084 options = options || {}; 51683 26085 var _options = options, _options$enabled = _options.enabled, enabled = _options$enabled === void 0 ? this.enabled : _options$enabled; 51684 26086 if (!enabled) { @@ -51692,7 +26094,7 @@ module.exports = { 51692 26094 }; 51693 26095 var result; 51694 26096 try {51695 -1 result = this.evaluate.call(helper, node.actualNode, checkOptions, node, context3);-1 26097 result = this.evaluate.call(helper, node.actualNode, checkOptions, node, context5); 51696 26098 } catch (e) { 51697 26099 if (node && node.actualNode) { 51698 26100 e.errorNode = new dq_element_default(node).toJSON(); @@ -51703,7 +26105,7 @@ module.exports = { 51703 26105 return checkResult; 51704 26106 }; 51705 26107 Check.prototype.configure = function configure(spec) {51706 -1 var _this3 = this;-1 26108 var _this4 = this; 51707 26109 if (!spec.evaluate || metadata_function_map_default[spec.evaluate]) { 51708 26110 this._internalCheck = true; 51709 26111 } @@ -51720,7 +26122,7 @@ module.exports = { 51720 26122 [ 'evaluate', 'after' ].filter(function(prop) { 51721 26123 return spec.hasOwnProperty(prop); 51722 26124 }).forEach(function(prop) {51723 -1 return _this3[prop] = createExecutionContext(spec[prop]);-1 26125 return _this4[prop] = createExecutionContext(spec[prop]); 51724 26126 }); 51725 26127 }; 51726 26128 Check.prototype.getOptions = function getOptions(options) { @@ -51763,7 +26165,7 @@ module.exports = { 51763 26165 Rule.prototype.matches = function matches13() { 51764 26166 return true; 51765 26167 };51766 -1 Rule.prototype.gather = function gather(context3) {-1 26168 Rule.prototype.gather = function gather(context5) { 51767 26169 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 51768 26170 var markStart = 'mark_gather_start_' + this.id; 51769 26171 var markEnd = 'mark_gather_end_' + this.id; @@ -51772,7 +26174,7 @@ module.exports = { 51772 26174 if (options.performanceTimer) { 51773 26175 performance_timer_default.mark(markStart); 51774 26176 }51775 -1 var elements = select_default(this.selector, context3);-1 26177 var elements = select_default(this.selector, context5); 51776 26178 if (this.excludeHidden) { 51777 26179 if (options.performanceTimer) { 51778 26180 performance_timer_default.mark(markHiddenStart); @@ -51791,14 +26193,14 @@ module.exports = { 51791 26193 } 51792 26194 return elements; 51793 26195 };51794 -1 Rule.prototype.runChecks = function runChecks(type, node, options, context3, resolve, reject) {-1 26196 Rule.prototype.runChecks = function runChecks(type, node, options, context5, resolve, reject) { 51795 26197 var self2 = this; 51796 26198 var checkQueue = queue_default(); 51797 26199 this[type].forEach(function(c) { 51798 26200 var check4 = self2._audit.checks[c.id || c]; 51799 26201 var option = get_check_option_default(check4, self2.id, options); 51800 26202 checkQueue.defer(function(res, rej) {51801 -1 check4.run(node, option, context3, res, rej);-1 26203 check4.run(node, option, context5, res, rej); 51802 26204 }); 51803 26205 }); 51804 26206 checkQueue.then(function(results) { @@ -51811,13 +26213,13 @@ module.exports = { 51811 26213 }); 51812 26214 })['catch'](reject); 51813 26215 };51814 -1 Rule.prototype.runChecksSync = function runChecksSync(type, node, options, context3) {-1 26216 Rule.prototype.runChecksSync = function runChecksSync(type, node, options, context5) { 51815 26217 var self2 = this; 51816 26218 var results = []; 51817 26219 this[type].forEach(function(c) { 51818 26220 var check4 = self2._audit.checks[c.id || c]; 51819 26221 var option = get_check_option_default(check4, self2.id, options);51820 -1 results.push(check4.runSync(node, option, context3));-1 26222 results.push(check4.runSync(node, option, context5)); 51821 26223 }); 51822 26224 results = results.filter(function(check4) { 51823 26225 return check4; @@ -51827,8 +26229,8 @@ module.exports = { 51827 26229 results: results 51828 26230 }; 51829 26231 };51830 -1 Rule.prototype.run = function run2(context3) {51831 -1 var _this4 = this;-1 26232 Rule.prototype.run = function run2(context5) { -1 26233 var _this5 = this; 51832 26234 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 51833 26235 var resolve = arguments.length > 2 ? arguments[2] : undefined; 51834 26236 var reject = arguments.length > 3 ? arguments[3] : undefined; @@ -51839,7 +26241,7 @@ module.exports = { 51839 26241 var ruleResult = new rule_result_default(this); 51840 26242 var nodes; 51841 26243 try {51842 -1 nodes = this.gatherAndMatchNodes(context3, options);-1 26244 nodes = this.gatherAndMatchNodes(context5, options); 51843 26245 } catch (error) { 51844 26246 reject(new SupportError({ 51845 26247 cause: error, @@ -51855,7 +26257,7 @@ module.exports = { 51855 26257 var checkQueue = queue_default(); 51856 26258 [ 'any', 'all', 'none' ].forEach(function(type) { 51857 26259 checkQueue.defer(function(res, rej) {51858 -1 _this4.runChecks(type, node, options, context3, res, rej);-1 26260 _this5.runChecks(type, node, options, context5, res, rej); 51859 26261 }); 51860 26262 }); 51861 26263 checkQueue.then(function(results) { @@ -51863,7 +26265,7 @@ module.exports = { 51863 26265 if (result) { 51864 26266 result.node = new dq_element_default(node, options); 51865 26267 ruleResult.nodes.push(result);51866 -1 if (_this4.reviewOnFail) {-1 26268 if (_this5.reviewOnFail) { 51867 26269 [ 'any', 'all' ].forEach(function(type) { 51868 26270 result[type].forEach(function(checkResult) { 51869 26271 if (checkResult.result === false) { @@ -51896,8 +26298,8 @@ module.exports = { 51896 26298 return reject(error); 51897 26299 }); 51898 26300 };51899 -1 Rule.prototype.runSync = function runSync2(context3) {51900 -1 var _this5 = this;-1 26301 Rule.prototype.runSync = function runSync2(context5) { -1 26302 var _this6 = this; 51901 26303 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 51902 26304 if (options.performanceTimer) { 51903 26305 this._trackPerformance(); @@ -51905,7 +26307,7 @@ module.exports = { 51905 26307 var ruleResult = new rule_result_default(this); 51906 26308 var nodes; 51907 26309 try {51908 -1 nodes = this.gatherAndMatchNodes(context3, options);-1 26310 nodes = this.gatherAndMatchNodes(context5, options); 51909 26311 } catch (error) { 51910 26312 throw new SupportError({ 51911 26313 cause: error, @@ -51918,13 +26320,13 @@ module.exports = { 51918 26320 nodes.forEach(function(node) { 51919 26321 var results = []; 51920 26322 [ 'any', 'all', 'none' ].forEach(function(type) {51921 -1 results.push(_this5.runChecksSync(type, node, options, context3));-1 26323 results.push(_this6.runChecksSync(type, node, options, context5)); 51922 26324 }); 51923 26325 var result = getResult(results); 51924 26326 if (result) { 51925 26327 result.node = node.actualNode ? new dq_element_default(node, options) : null; 51926 26328 ruleResult.nodes.push(result);51927 -1 if (_this5.reviewOnFail) {-1 26329 if (_this6.reviewOnFail) { 51928 26330 [ 'any', 'all' ].forEach(function(type) { 51929 26331 result[type].forEach(function(checkResult) { 51930 26332 if (checkResult.result === false) { @@ -51980,16 +26382,16 @@ module.exports = { 51980 26382 return null; 51981 26383 } 51982 26384 }51983 -1 Rule.prototype.gatherAndMatchNodes = function gatherAndMatchNodes(context3, options) {51984 -1 var _this6 = this;-1 26385 Rule.prototype.gatherAndMatchNodes = function gatherAndMatchNodes(context5, options) { -1 26386 var _this7 = this; 51985 26387 var markMatchesStart = 'mark_matches_start_' + this.id; 51986 26388 var markMatchesEnd = 'mark_matches_end_' + this.id;51987 -1 var nodes = this.gather(context3, options);-1 26389 var nodes = this.gather(context5, options); 51988 26390 if (options.performanceTimer) { 51989 26391 performance_timer_default.mark(markMatchesStart); 51990 26392 } 51991 26393 nodes = nodes.filter(function(node) {51992 -1 return _this6.matches(node.actualNode, node, context3);-1 26394 return _this7.matches(node.actualNode, node, context5); 51993 26395 }); 51994 26396 if (options.performanceTimer) { 51995 26397 performance_timer_default.mark(markMatchesEnd); @@ -52202,8 +26604,8 @@ module.exports = { 52202 26604 lang: this.lang 52203 26605 }; 52204 26606 var checkIDs = Object.keys(this.data.checks);52205 -1 for (var _i23 = 0; _i23 < checkIDs.length; _i23++) {52206 -1 var id = checkIDs[_i23];-1 26607 for (var _i24 = 0; _i24 < checkIDs.length; _i24++) { -1 26608 var id = checkIDs[_i24]; 52207 26609 var check4 = this.data.checks[id]; 52208 26610 var _check4$messages = check4.messages, pass = _check4$messages.pass, fail = _check4$messages.fail, incomplete = _check4$messages.incomplete; 52209 26611 locale.checks[id] = { @@ -52213,8 +26615,8 @@ module.exports = { 52213 26615 }; 52214 26616 } 52215 26617 var ruleIDs = Object.keys(this.data.rules);52216 -1 for (var _i24 = 0; _i24 < ruleIDs.length; _i24++) {52217 -1 var _id = ruleIDs[_i24];-1 26618 for (var _i25 = 0; _i25 < ruleIDs.length; _i25++) { -1 26619 var _id = ruleIDs[_i25]; 52218 26620 var rule3 = this.data.rules[_id]; 52219 26621 var description = rule3.description, help = rule3.help; 52220 26622 locale.rules[_id] = { @@ -52223,8 +26625,8 @@ module.exports = { 52223 26625 }; 52224 26626 } 52225 26627 var failureSummaries = Object.keys(this.data.failureSummaries);52226 -1 for (var _i25 = 0; _i25 < failureSummaries.length; _i25++) {52227 -1 var type = failureSummaries[_i25];-1 26628 for (var _i26 = 0; _i26 < failureSummaries.length; _i26++) { -1 26629 var type = failureSummaries[_i26]; 52228 26630 var failureSummary2 = this.data.failureSummaries[type]; 52229 26631 var failureMessage = failureSummary2.failureMessage; 52230 26632 locale.failureSummaries[type] = { @@ -52247,8 +26649,8 @@ module.exports = { 52247 26649 key: '_applyCheckLocale', 52248 26650 value: function _applyCheckLocale(checks) { 52249 26651 var keys = Object.keys(checks);52250 -1 for (var _i26 = 0; _i26 < keys.length; _i26++) {52251 -1 var id = keys[_i26];-1 26652 for (var _i27 = 0; _i27 < keys.length; _i27++) { -1 26653 var id = keys[_i27]; 52252 26654 if (!this.data.checks[id]) { 52253 26655 throw new Error('Locale provided for unknown check: "'.concat(id, '"')); 52254 26656 } @@ -52259,8 +26661,8 @@ module.exports = { 52259 26661 key: '_applyRuleLocale', 52260 26662 value: function _applyRuleLocale(rules) { 52261 26663 var keys = Object.keys(rules);52262 -1 for (var _i27 = 0; _i27 < keys.length; _i27++) {52263 -1 var id = keys[_i27];-1 26664 for (var _i28 = 0; _i28 < keys.length; _i28++) { -1 26665 var id = keys[_i28]; 52264 26666 if (!this.data.rules[id]) { 52265 26667 throw new Error('Locale provided for unknown rule: "'.concat(id, '"')); 52266 26668 } @@ -52271,8 +26673,8 @@ module.exports = { 52271 26673 key: '_applyFailureSummaries', 52272 26674 value: function _applyFailureSummaries(messages) { 52273 26675 var keys = Object.keys(messages);52274 -1 for (var _i28 = 0; _i28 < keys.length; _i28++) {52275 -1 var key = keys[_i28];-1 26676 for (var _i29 = 0; _i29 < keys.length; _i29++) { -1 26677 var key = keys[_i29]; 52276 26678 if (!this.data.failureSummaries[key]) { 52277 26679 throw new Error('Locale provided for unknown failureMessage: "'.concat(key, '"')); 52278 26680 } @@ -52304,10 +26706,10 @@ module.exports = { 52304 26706 value: function setAllowedOrigins(allowedOrigins) { 52305 26707 var defaultOrigin = getDefaultOrigin(); 52306 26708 this.allowedOrigins = [];52307 -1 var _iterator2 = _createForOfIteratorHelper(allowedOrigins), _step2;-1 26709 var _iterator3 = _createForOfIteratorHelper(allowedOrigins), _step3; 52308 26710 try {52309 -1 for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {52310 -1 var origin = _step2.value;-1 26711 for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) { -1 26712 var origin = _step3.value; 52311 26713 if (origin === constants_default.allOrigins) { 52312 26714 this.allowedOrigins = [ '*' ]; 52313 26715 return; @@ -52318,9 +26720,9 @@ module.exports = { 52318 26720 } 52319 26721 } 52320 26722 } catch (err) {52321 -1 _iterator2.e(err);-1 26723 _iterator3.e(err); 52322 26724 } finally {52323 -1 _iterator2.f();-1 26725 _iterator3.f(); 52324 26726 } 52325 26727 } 52326 26728 }, { @@ -52388,15 +26790,15 @@ module.exports = { 52388 26790 } 52389 26791 }, { 52390 26792 key: 'run',52391 -1 value: function run(context3, options, resolve, reject) {-1 26793 value: function run(context5, options, resolve, reject) { 52392 26794 this.normalizeOptions(options); 52393 26795 axe._selectCache = [];52394 -1 var allRulesToRun = getRulesToRun(this.rules, context3, options);-1 26796 var allRulesToRun = getRulesToRun(this.rules, context5, options); 52395 26797 var runNowRules = allRulesToRun.now; 52396 26798 var runLaterRules = allRulesToRun.later; 52397 26799 var nowRulesQueue = queue_default(); 52398 26800 runNowRules.forEach(function(rule3) {52399 -1 nowRulesQueue.defer(getDefferedRule(rule3, context3, options));-1 26801 nowRulesQueue.defer(getDefferedRule(rule3, context5, options)); 52400 26802 }); 52401 26803 var preloaderQueue = queue_default(); 52402 26804 if (runLaterRules.length) { @@ -52417,7 +26819,7 @@ module.exports = { 52417 26819 if (assetsFromQueue && assetsFromQueue.length) { 52418 26820 var assets = assetsFromQueue[0]; 52419 26821 if (assets) {52420 -1 context3 = _extends({}, context3, assets);-1 26822 context5 = _extends({}, context5, assets); 52421 26823 } 52422 26824 } 52423 26825 var nowRulesResults = nowRulesAndPreloaderResults[0]; @@ -52430,7 +26832,7 @@ module.exports = { 52430 26832 } 52431 26833 var laterRulesQueue = queue_default(); 52432 26834 runLaterRules.forEach(function(rule3) {52433 -1 var deferredRule = getDefferedRule(rule3, context3, options);-1 26835 var deferredRule = getDefferedRule(rule3, context5, options); 52434 26836 laterRulesQueue.defer(deferredRule); 52435 26837 }); 52436 26838 laterRulesQueue.then(function(laterRuleResults) { @@ -52474,7 +26876,10 @@ module.exports = { 52474 26876 } 52475 26877 }); 52476 26878 });52477 -1 if (_typeof(options.runOnly) === 'object') {-1 26879 if ([ 'object', 'string' ].includes(_typeof(options.runOnly))) { -1 26880 if (typeof options.runOnly === 'string') { -1 26881 options.runOnly = [ options.runOnly ]; -1 26882 } 52478 26883 if (Array.isArray(options.runOnly)) { 52479 26884 var hasTag = options.runOnly.find(function(value) { 52480 26885 return tags.includes(value); @@ -52515,10 +26920,10 @@ module.exports = { 52515 26920 } else if ([ 'tag', 'tags', void 0 ].includes(only.type)) { 52516 26921 only.type = 'tag'; 52517 26922 var unmatchedTags = only.values.filter(function(tag) {52518 -1 return !tags.includes(tag);-1 26923 return !tags.includes(tag) && !/wcag2[1-3]a{1,3}/.test(tag); 52519 26924 }); 52520 26925 if (unmatchedTags.length !== 0) {52521 -1 log_default('Could not find tags `' + unmatchedTags.join('`, `') + '`');-1 26926 axe.log('Could not find tags `' + unmatchedTags.join('`, `') + '`'); 52522 26927 } 52523 26928 } else { 52524 26929 throw new Error('Unknown runOnly type \''.concat(only.type, '\'')); @@ -52540,6 +26945,9 @@ module.exports = { 52540 26945 brand: this.brand, 52541 26946 application: this.application 52542 26947 }; -1 26948 if (typeof branding === 'string') { -1 26949 this.application = branding; -1 26950 } 52543 26951 if (branding && branding.hasOwnProperty('brand') && branding.brand && typeof branding.brand === 'string') { 52544 26952 this.brand = branding.brand; 52545 26953 } @@ -52551,16 +26959,16 @@ module.exports = { 52551 26959 }, { 52552 26960 key: '_constructHelpUrls', 52553 26961 value: function _constructHelpUrls() {52554 -1 var _this7 = this;-1 26962 var _this8 = this; 52555 26963 var previous = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 52556 26964 var version = (axe.version.match(/^[1-9][0-9]*\.[0-9]+/) || [ 'x.y' ])[0]; 52557 26965 this.rules.forEach(function(rule3) {52558 -1 if (!_this7.data.rules[rule3.id]) {52559 -1 _this7.data.rules[rule3.id] = {};-1 26966 if (!_this8.data.rules[rule3.id]) { -1 26967 _this8.data.rules[rule3.id] = {}; 52560 26968 }52561 -1 var metaData = _this7.data.rules[rule3.id];-1 26969 var metaData = _this8.data.rules[rule3.id]; 52562 26970 if (typeof metaData.helpUrl !== 'string' || previous && metaData.helpUrl === getHelpUrl(previous, rule3.id, version)) {52563 -1 metaData.helpUrl = getHelpUrl(_this7, rule3.id, version);-1 26971 metaData.helpUrl = getHelpUrl(_this8, rule3.id, version); 52564 26972 } 52565 26973 }); 52566 26974 } @@ -52573,13 +26981,13 @@ module.exports = { 52573 26981 } ]); 52574 26982 return Audit; 52575 26983 }();52576 -1 function getRulesToRun(rules, context3, options) {-1 26984 function getRulesToRun(rules, context5, options) { 52577 26985 var base = { 52578 26986 now: [], 52579 26987 later: [] 52580 26988 }; 52581 26989 var splitRules = rules.reduce(function(out, rule3) {52582 -1 if (!rule_should_run_default(rule3, context3, options)) {-1 26990 if (!rule_should_run_default(rule3, context5, options)) { 52583 26991 return out; 52584 26992 } 52585 26993 if (rule3.preload) { @@ -52591,12 +26999,12 @@ module.exports = { 52591 26999 }, base); 52592 27000 return splitRules; 52593 27001 }52594 -1 function getDefferedRule(rule3, context3, options) {-1 27002 function getDefferedRule(rule3, context5, options) { 52595 27003 if (options.performanceTimer) { 52596 27004 performance_timer_default.mark('mark_rule_start_' + rule3.id); 52597 27005 } 52598 27006 return function(resolve, reject) {52599 -1 rule3.run(context3, options, function(ruleResult) {-1 27007 rule3.run(context5, options, function(ruleResult) { 52600 27008 resolve(ruleResult); 52601 27009 }, function(err2) { 52602 27010 if (!options.debug) { @@ -52615,168 +27023,11 @@ module.exports = { 52615 27023 }); 52616 27024 }; 52617 27025 }52618 -1 function getHelpUrl(_ref71, ruleId, version) {52619 -1 var brand = _ref71.brand, application = _ref71.application, lang = _ref71.lang;-1 27026 function getHelpUrl(_ref86, ruleId, version) { -1 27027 var brand = _ref86.brand, application = _ref86.application, lang = _ref86.lang; 52620 27028 return constants_default.helpUrlBase + brand + '/' + (version || axe.version.substring(0, axe.version.lastIndexOf('.'))) + '/' + ruleId + '?application=' + encodeURIComponent(application) + (lang && lang !== 'en' ? '&lang=' + encodeURIComponent(lang) : ''); 52621 27029 } 52622 27030 var audit_default = Audit;52623 -1 function pushUniqueFrame(collection, frame) {52624 -1 if (is_hidden_default(frame)) {52625 -1 return;52626 -1 }52627 -1 var fr = find_by_default(collection, 'node', frame);52628 -1 if (!fr) {52629 -1 collection.push({52630 -1 node: frame,52631 -1 include: [],52632 -1 exclude: []52633 -1 });52634 -1 }52635 -1 }52636 -1 function pushUniqueFrameSelector(context3, type, selectorArray) {52637 -1 context3.frames = context3.frames || [];52638 -1 var result, frame;52639 -1 var frames = document.querySelectorAll(selectorArray.shift());52640 -1 frameloop: for (var i = 0, l = frames.length; i < l; i++) {52641 -1 frame = frames[i];52642 -1 for (var j = 0, l2 = context3.frames.length; j < l2; j++) {52643 -1 if (context3.frames[j].node === frame) {52644 -1 context3.frames[j][type].push(selectorArray);52645 -1 break frameloop;52646 -1 }52647 -1 }52648 -1 result = {52649 -1 node: frame,52650 -1 include: [],52651 -1 exclude: []52652 -1 };52653 -1 if (selectorArray) {52654 -1 result[type].push(selectorArray);52655 -1 }52656 -1 context3.frames.push(result);52657 -1 }52658 -1 }52659 -1 function normalizeContext(context3) {52660 -1 if (context3 && _typeof(context3) === 'object' || context3 instanceof window.NodeList) {52661 -1 if (context3 instanceof window.Node) {52662 -1 return {52663 -1 include: [ context3 ],52664 -1 exclude: []52665 -1 };52666 -1 }52667 -1 if (context3.hasOwnProperty('include') || context3.hasOwnProperty('exclude')) {52668 -1 return {52669 -1 include: context3.include && +context3.include.length ? context3.include : [ document ],52670 -1 exclude: context3.exclude || []52671 -1 };52672 -1 }52673 -1 if (context3.length === +context3.length) {52674 -1 return {52675 -1 include: context3,52676 -1 exclude: []52677 -1 };52678 -1 }52679 -1 }52680 -1 if (typeof context3 === 'string') {52681 -1 return {52682 -1 include: [ context3 ],52683 -1 exclude: []52684 -1 };52685 -1 }52686 -1 return {52687 -1 include: [ document ],52688 -1 exclude: []52689 -1 };52690 -1 }52691 -1 function parseSelectorArray(context3, type) {52692 -1 var item, result = [], nodeList;52693 -1 for (var i = 0, l = context3[type].length; i < l; i++) {52694 -1 item = context3[type][i];52695 -1 if (typeof item === 'string') {52696 -1 nodeList = Array.from(document.querySelectorAll(item));52697 -1 result = result.concat(nodeList.map(function(node) {52698 -1 return get_node_from_tree_default(node);52699 -1 }));52700 -1 break;52701 -1 } else if (item && item.length && !(item instanceof window.Node)) {52702 -1 if (item.length > 1) {52703 -1 pushUniqueFrameSelector(context3, type, item);52704 -1 } else {52705 -1 nodeList = Array.from(document.querySelectorAll(item[0]));52706 -1 result = result.concat(nodeList.map(function(node) {52707 -1 return get_node_from_tree_default(node);52708 -1 }));52709 -1 }52710 -1 } else if (item instanceof window.Node) {52711 -1 if (item.documentElement instanceof window.Node) {52712 -1 result.push(context3.flatTree[0]);52713 -1 } else {52714 -1 result.push(get_node_from_tree_default(item));52715 -1 }52716 -1 }52717 -1 }52718 -1 return result.filter(function(r) {52719 -1 return r;52720 -1 });52721 -1 }52722 -1 function validateContext(context3) {52723 -1 if (context3.include.length === 0) {52724 -1 if (context3.frames.length === 0) {52725 -1 var env = _respondable.isInFrame() ? 'frame' : 'page';52726 -1 return new Error('No elements found for include in ' + env + ' Context');52727 -1 }52728 -1 context3.frames.forEach(function(frame, i) {52729 -1 if (frame.include.length === 0) {52730 -1 return new Error('No elements found for include in Context of frame ' + i);52731 -1 }52732 -1 });52733 -1 }52734 -1 }52735 -1 function getRootNode2(_ref72) {52736 -1 var include = _ref72.include, exclude = _ref72.exclude;52737 -1 var selectors = Array.from(include).concat(Array.from(exclude));52738 -1 for (var i = 0; i < selectors.length; ++i) {52739 -1 var item = selectors[i];52740 -1 if (item instanceof window.Element) {52741 -1 return item.ownerDocument.documentElement;52742 -1 }52743 -1 if (item instanceof window.Document) {52744 -1 return item.documentElement;52745 -1 }52746 -1 }52747 -1 return document.documentElement;52748 -1 }52749 -1 function Context(spec) {52750 -1 var _this8 = this;52751 -1 this.frames = [];52752 -1 this.initiator = spec && typeof spec.initiator === 'boolean' ? spec.initiator : true;52753 -1 this.focusable = spec && typeof spec.focusable === 'boolean' ? spec.focusable : true;52754 -1 this.boundingClientRect = spec && _typeof(spec.boundingClientRect) === 'object' ? spec.boundingClientRect : {};52755 -1 this.page = false;52756 -1 spec = normalizeContext(spec);52757 -1 this.flatTree = get_flattened_tree_default(getRootNode2(spec));52758 -1 this.exclude = spec.exclude;52759 -1 this.include = spec.include;52760 -1 this.include = parseSelectorArray(this, 'include');52761 -1 this.exclude = parseSelectorArray(this, 'exclude');52762 -1 select_default('frame, iframe', this).forEach(function(frame) {52763 -1 if (is_node_in_context_default(frame, _this8)) {52764 -1 pushUniqueFrame(_this8.frames, frame.actualNode);52765 -1 }52766 -1 });52767 -1 if (this.include.length === 1 && this.include[0].actualNode === document.documentElement) {52768 -1 this.page = true;52769 -1 }52770 -1 var err2 = validateContext(this);52771 -1 if (err2 instanceof Error) {52772 -1 throw err2;52773 -1 }52774 -1 if (!Array.isArray(this.include)) {52775 -1 this.include = Array.from(this.include);52776 -1 }52777 -1 this.include.sort(node_sorter_default);52778 -1 }52779 -1 var context_default = Context;52780 27031 var imports_exports = {}; 52781 27032 __export(imports_exports, { 52782 27033 CssSelectorParser: function CssSelectorParser() { @@ -52799,6 +27050,7 @@ module.exports = { 52799 27050 var es6_promise = __toModule(require_es6_promise()); 52800 27051 var typedarray = __toModule(require_typedarray()); 52801 27052 var weakmap_polyfill = __toModule(require_weakmap_polyfill()); -1 27053 dot2['default'].templateSettings.strip = false; 52802 27054 if (!('Promise' in window)) { 52803 27055 es6_promise['default'].polyfill(); 52804 27056 } @@ -52860,12 +27112,12 @@ module.exports = { 52860 27112 function hasReporter(reporterName) { 52861 27113 return reporters.hasOwnProperty(reporterName); 52862 27114 }52863 -1 function getReporter(reporter4) {52864 -1 if (typeof reporter4 === 'string' && reporters[reporter4]) {52865 -1 return reporters[reporter4];-1 27115 function getReporter(reporter5) { -1 27116 if (typeof reporter5 === 'string' && reporters[reporter5]) { -1 27117 return reporters[reporter5]; 52866 27118 }52867 -1 if (typeof reporter4 === 'function') {52868 -1 return reporter4;-1 27119 if (typeof reporter5 === 'function') { -1 27120 return reporter5; 52869 27121 } 52870 27122 return defaultReporter; 52871 27123 } @@ -52979,13 +27231,36 @@ module.exports = { 52979 27231 }); 52980 27232 } 52981 27233 var get_rules_default = getRules;52982 -1 function teardown() {-1 27234 function setupGlobals(context5) { -1 27235 var hasWindow = window && 'Node' in window && 'NodeList' in window; -1 27236 var hasDoc = !!document; -1 27237 if (hasWindow && hasDoc) { -1 27238 return; -1 27239 } -1 27240 if (!context5 || !context5.ownerDocument) { -1 27241 throw new Error('Required "window" or "document" globals not defined and cannot be deduced from the context. Either set the globals before running or pass in a valid Element.'); -1 27242 } -1 27243 if (!hasDoc) { -1 27244 cache_default.set('globalDocumentSet', true); -1 27245 document = context5.ownerDocument; -1 27246 } -1 27247 if (!hasWindow) { -1 27248 cache_default.set('globalWindowSet', true); -1 27249 window = document.defaultView; -1 27250 } -1 27251 } -1 27252 function resetGlobals() { 52983 27253 if (cache_default.get('globalDocumentSet')) { -1 27254 cache_default.set('globalDocumentSet', false); 52984 27255 document = null; 52985 27256 } 52986 27257 if (cache_default.get('globalWindowSet')) { -1 27258 cache_default.set('globalWindowSet', false); 52987 27259 window = null; 52988 27260 } -1 27261 } -1 27262 function teardown() { -1 27263 resetGlobals(); 52989 27264 axe._memoizedFns.forEach(function(fn) { 52990 27265 return fn.clear(); 52991 27266 }); @@ -52995,11 +27270,11 @@ module.exports = { 52995 27270 axe._selectCache = void 0; 52996 27271 } 52997 27272 var teardown_default = teardown;52998 -1 function runRules(context3, options, resolve, reject) {-1 27273 function runRules(context5, options, resolve, reject) { 52999 27274 try {53000 -1 context3 = new context_default(context3);53001 -1 axe._tree = context3.flatTree;53002 -1 axe._selectorData = _getSelectorData(context3.flatTree);-1 27275 context5 = new Context(context5); -1 27276 axe._tree = context5.flatTree; -1 27277 axe._selectorData = _getSelectorData(context5.flatTree); 53003 27278 } catch (e) { 53004 27279 teardown_default(); 53005 27280 return reject(e); @@ -53009,13 +27284,13 @@ module.exports = { 53009 27284 if (options.performanceTimer) { 53010 27285 performance_timer_default.auditStart(); 53011 27286 }53012 -1 if (context3.frames.length && options.iframes !== false) {-1 27287 if (context5.frames.length && options.iframes !== false) { 53013 27288 q.defer(function(res, rej) {53014 -1 collect_results_from_frames_default(context3, options, 'rules', null, res, rej);-1 27289 _collectResultsFromFrames(context5, options, 'rules', null, res, rej); 53015 27290 }); 53016 27291 } 53017 27292 q.defer(function(res, rej) {53018 -1 audit3.run(context3, options, res, rej);-1 27293 audit3.run(context5, options, res, rej); 53019 27294 }); 53020 27295 q.then(function(data2) { 53021 27296 try { @@ -53027,7 +27302,7 @@ module.exports = { 53027 27302 results: results2 53028 27303 }; 53029 27304 }));53030 -1 if (context3.initiator) {-1 27305 if (context5.initiator) { 53031 27306 results = audit3.after(results, options); 53032 27307 results.forEach(publish_metadata_default); 53033 27308 results = results.map(finalize_result_default); @@ -53056,14 +27331,14 @@ module.exports = { 53056 27331 } 53057 27332 callback(err2); 53058 27333 };53059 -1 var context3 = data2 && data2.context || {};53060 -1 if (context3.hasOwnProperty('include') && !context3.include.length) {53061 -1 context3.include = [ document ];-1 27334 var context5 = data2 && data2.context || {}; -1 27335 if (context5.hasOwnProperty('include') && !context5.include.length) { -1 27336 context5.include = [ document ]; 53062 27337 } 53063 27338 var options = data2 && data2.options || {}; 53064 27339 switch (data2.command) { 53065 27340 case 'rules':53066 -1 return run_rules_default(context3, options, function(results, cleanup5) {-1 27341 return run_rules_default(context5, options, function(results, cleanup5) { 53067 27342 resolve(results); 53068 27343 cleanup5(); 53069 27344 }, reject); @@ -53145,11 +27420,11 @@ module.exports = { 53145 27420 value: false 53146 27421 } 53147 27422 });53148 -1 var context3 = {-1 27423 var context5 = { 53149 27424 initiator: true, 53150 27425 include: [ vNode ] 53151 27426 };53152 -1 var rawResults = rule3.runSync(context3, options);-1 27427 var rawResults = rule3.runSync(context5, options); 53153 27428 publish_metadata_default(rawResults); 53154 27429 finalize_result_default(rawResults); 53155 27430 var results = aggregate_result_default([ rawResults ]); @@ -53158,41 +27433,22 @@ module.exports = { 53158 27433 nodeResult.failureSummary = failure_summary_default(nodeResult); 53159 27434 }); 53160 27435 });53161 -1 return _extends({}, get_environment_data_default(), results, {-1 27436 return _extends({}, _getEnvironmentData(), results, { 53162 27437 toolOptions: options 53163 27438 }); 53164 27439 } 53165 27440 var run_virtual_rule_default = runVirtualRule;53166 -1 function isContext(potential) {53167 -1 switch (true) {53168 -1 case typeof potential === 'string':53169 -1 case Array.isArray(potential):53170 -1 case window.Node && potential instanceof window.Node:53171 -1 case window.NodeList && potential instanceof window.NodeList:53172 -1 return true;53173 -153174 -1 case _typeof(potential) !== 'object':53175 -1 return false;53176 -153177 -1 case potential.include !== void 0:53178 -1 case potential.exclude !== void 0:53179 -1 case typeof potential.length === 'number':53180 -1 return true;53181 -153182 -1 default:53183 -1 return false;53184 -1 }53185 -1 }53186 -1 var noop2 = function noop3() {};53187 -1 function normalizeRunParams(context3, options, callback) {-1 27441 function normalizeRunParams(_ref87) { -1 27442 var _ref89, _options$reporter, _axe$_audit; -1 27443 var _ref88 = _slicedToArray(_ref87, 3), context5 = _ref88[0], options = _ref88[1], callback = _ref88[2]; 53188 27444 var typeErr = new TypeError('axe.run arguments are invalid');53189 -1 if (!isContext(context3)) {-1 27445 if (!isContext(context5)) { 53190 27446 if (callback !== void 0) { 53191 27447 throw typeErr; 53192 27448 } 53193 27449 callback = options;53194 -1 options = context3;53195 -1 context3 = document;-1 27450 options = context5; -1 27451 context5 = document; 53196 27452 } 53197 27453 if (_typeof(options) !== 'object') { 53198 27454 if (callback !== void 0) { @@ -53204,56 +27460,53 @@ module.exports = { 53204 27460 if (typeof callback !== 'function' && callback !== void 0) { 53205 27461 throw typeErr; 53206 27462 } -1 27463 options = clone_default(options); -1 27464 options.reporter = (_ref89 = (_options$reporter = options.reporter) !== null && _options$reporter !== void 0 ? _options$reporter : (_axe$_audit = axe._audit) === null || _axe$_audit === void 0 ? void 0 : _axe$_audit.reporter) !== null && _ref89 !== void 0 ? _ref89 : 'v1'; 53207 27465 return {53208 -1 context: context3,-1 27466 context: context5, 53209 27467 options: options,53210 -1 callback: callback || noop2-1 27468 callback: callback 53211 27469 }; 53212 27470 }53213 -1 function run4(context3, options, callback) {53214 -1 if (!axe._audit) {53215 -1 throw new Error('No audit configured');-1 27471 function isContext(potential) { -1 27472 switch (true) { -1 27473 case typeof potential === 'string': -1 27474 case Array.isArray(potential): -1 27475 case window.Node && potential instanceof window.Node: -1 27476 case window.NodeList && potential instanceof window.NodeList: -1 27477 return true; -1 27478 -1 27479 case _typeof(potential) !== 'object': -1 27480 return false; -1 27481 -1 27482 case potential.include !== void 0: -1 27483 case potential.exclude !== void 0: -1 27484 case typeof potential.length === 'number': -1 27485 return true; -1 27486 -1 27487 default: -1 27488 return false; 53216 27489 }53217 -1 var hasWindow = window && 'Node' in window && 'NodeList' in window;53218 -1 var hasDoc = !!document;53219 -1 if (!hasWindow || !hasDoc) {53220 -1 if (!context3 || !context3.ownerDocument) {53221 -1 throw new Error('Required "window" or "document" globals not defined and cannot be deduced from the context. Either set the globals before running or pass in a valid Element.');53222 -1 }53223 -1 if (!hasDoc) {53224 -1 cache_default.set('globalDocumentSet', true);53225 -1 document = context3.ownerDocument;53226 -1 }53227 -1 if (!hasWindow) {53228 -1 cache_default.set('globalWindowSet', true);53229 -1 window = document.defaultView;53230 -1 }-1 27490 } -1 27491 var noop2 = function noop2() {}; -1 27492 function run4() { -1 27493 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { -1 27494 args[_key2] = arguments[_key2]; 53231 27495 }53232 -1 var args = normalizeRunParams(context3, options, callback);53233 -1 context3 = args.context;53234 -1 options = args.options;53235 -1 callback = args.callback;53236 -1 options.reporter = options.reporter || axe._audit.reporter || 'v1';-1 27496 setupGlobals(args[0]); -1 27497 var _normalizeRunParams = normalizeRunParams(args), context5 = _normalizeRunParams.context, options = _normalizeRunParams.options, _normalizeRunParams$c = _normalizeRunParams.callback, callback = _normalizeRunParams$c === void 0 ? noop2 : _normalizeRunParams$c; -1 27498 var _getPromiseHandlers = getPromiseHandlers(callback), thenable = _getPromiseHandlers.thenable, resolve = _getPromiseHandlers.resolve, reject = _getPromiseHandlers.reject; -1 27499 try { -1 27500 assert_default(axe._audit, 'No audit configured'); -1 27501 assert_default(!axe._running, 'Axe is already running. Use `await axe.run()` to wait for the previous run to finish before starting a new run.'); -1 27502 } catch (e) { -1 27503 return handleError(e, callback); -1 27504 } -1 27505 axe._running = true; 53237 27506 if (options.performanceTimer) { 53238 27507 axe.utils.performanceTimer.start(); 53239 27508 }53240 -1 var p;53241 -1 var reject = noop2;53242 -1 var resolve = noop2;53243 -1 if (typeof Promise === 'function' && callback === noop2) {53244 -1 p = new Promise(function(_resolve, _reject) {53245 -1 reject = _reject;53246 -1 resolve = _resolve;53247 -1 });53248 -1 }53249 -1 if (axe._running) {53250 -1 var err2 = 'Axe is already running. Use `await axe.run()` to wait for the previous run to finish before starting a new run.';53251 -1 callback(err2);53252 -1 reject(err2);53253 -1 return p;53254 -1 }53255 -1 axe._running = true;53256 -1 axe._runRules(context3, options, function(rawResults, cleanup5) {-1 27509 function handleRunRules(rawResults, cleanup5) { 53257 27510 var respond = function respond(results) { 53258 27511 axe._running = false; 53259 27512 cleanup5(); @@ -53268,25 +27521,167 @@ module.exports = { 53268 27521 axe.utils.performanceTimer.end(); 53269 27522 } 53270 27523 try {53271 -1 var reporter4 = getReporter(options.reporter);53272 -1 var results = reporter4(rawResults, options, respond);53273 -1 if (results !== void 0) {53274 -1 respond(results);53275 -1 }-1 27524 createReport(rawResults, options, respond); 53276 27525 } catch (err2) { 53277 27526 axe._running = false; 53278 27527 cleanup5(); 53279 27528 callback(err2); 53280 27529 reject(err2); 53281 27530 }53282 -1 }, function(err2) {-1 27531 } -1 27532 function errorRunRules(err2) { -1 27533 if (options.performanceTimer) { -1 27534 axe.utils.performanceTimer.end(); -1 27535 } 53283 27536 axe._running = false; -1 27537 resetGlobals(); 53284 27538 callback(err2); 53285 27539 reject(err2); -1 27540 } -1 27541 axe._runRules(context5, options, handleRunRules, errorRunRules); -1 27542 return thenable; -1 27543 } -1 27544 function getPromiseHandlers(callback) { -1 27545 var thenable, reject, resolve; -1 27546 if (typeof Promise === 'function' && callback === noop2) { -1 27547 thenable = new Promise(function(_resolve, _reject) { -1 27548 reject = _reject; -1 27549 resolve = _resolve; -1 27550 }); -1 27551 } else { -1 27552 resolve = reject = noop2; -1 27553 } -1 27554 return { -1 27555 thenable: thenable, -1 27556 reject: reject, -1 27557 resolve: resolve -1 27558 }; -1 27559 } -1 27560 function createReport(rawResults, options, respond) { -1 27561 var reporter5 = getReporter(options.reporter); -1 27562 var results = reporter5(rawResults, options, respond); -1 27563 if (results !== void 0) { -1 27564 respond(results); -1 27565 } -1 27566 } -1 27567 function handleError(err2, callback) { -1 27568 resetGlobals(); -1 27569 if (typeof callback === 'function' && callback !== noop2) { -1 27570 callback(err2.message); -1 27571 return; -1 27572 } -1 27573 throw err2; -1 27574 } -1 27575 function runPartial() { -1 27576 for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { -1 27577 args[_key3] = arguments[_key3]; -1 27578 } -1 27579 var _normalizeRunParams2 = normalizeRunParams(args), options = _normalizeRunParams2.options, context5 = _normalizeRunParams2.context; -1 27580 assert_default(axe._audit, 'Axe is not configured. Audit is missing.'); -1 27581 assert_default(!axe._running, 'Axe is already running. Use `await axe.run()` to wait for the previous run to finish before starting a new run.'); -1 27582 var contextObj = new Context(context5, axe._tree); -1 27583 axe._tree = contextObj.flatTree; -1 27584 axe._selectorData = _getSelectorData(contextObj.flatTree); -1 27585 axe._running = true; -1 27586 return new Promise(function(res, rej) { -1 27587 axe._audit.run(contextObj, options, res, rej); -1 27588 }).then(function(results) { -1 27589 results = results.map(function(_ref90) { -1 27590 var nodes = _ref90.nodes, result = _objectWithoutProperties(_ref90, _excluded8); -1 27591 return _extends({ -1 27592 nodes: nodes.map(serializeNode) -1 27593 }, result); -1 27594 }); -1 27595 var frames = contextObj.frames.map(function(_ref91) { -1 27596 var node = _ref91.node; -1 27597 return new dq_element_default(node, options).toJSON(); -1 27598 }); -1 27599 var environmentData; -1 27600 if (contextObj.initiator) { -1 27601 environmentData = _getEnvironmentData(); -1 27602 } -1 27603 axe._running = false; -1 27604 teardown_default(); -1 27605 return { -1 27606 results: results, -1 27607 frames: frames, -1 27608 environmentData: environmentData -1 27609 }; -1 27610 })['catch'](function(err2) { -1 27611 axe._running = false; -1 27612 teardown_default(); -1 27613 return Promise.reject(err2); -1 27614 }); -1 27615 } -1 27616 function serializeNode(_ref92) { -1 27617 var node = _ref92.node, nodeResult = _objectWithoutProperties(_ref92, _excluded9); -1 27618 nodeResult.node = node.toJSON(); -1 27619 for (var _i30 = 0, _arr2 = [ 'any', 'all', 'none' ]; _i30 < _arr2.length; _i30++) { -1 27620 var type = _arr2[_i30]; -1 27621 nodeResult[type] = nodeResult[type].map(function(_ref93) { -1 27622 var relatedNodes = _ref93.relatedNodes, checkResult = _objectWithoutProperties(_ref93, _excluded10); -1 27623 return _extends({}, checkResult, { -1 27624 relatedNodes: relatedNodes.map(function(node2) { -1 27625 return node2.toJSON(); -1 27626 }) -1 27627 }); -1 27628 }); -1 27629 } -1 27630 return nodeResult; -1 27631 } -1 27632 function finishRun(partialResults) { -1 27633 var _ref95, _options$reporter2, _axe$_audit2; -1 27634 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; -1 27635 options = clone_default(options); -1 27636 var _ref94 = partialResults.find(function(r) { -1 27637 return r.environmentData; -1 27638 }) || {}, environmentData = _ref94.environmentData; -1 27639 axe._audit.normalizeOptions(options); -1 27640 options.reporter = (_ref95 = (_options$reporter2 = options.reporter) !== null && _options$reporter2 !== void 0 ? _options$reporter2 : (_axe$_audit2 = axe._audit) === null || _axe$_audit2 === void 0 ? void 0 : _axe$_audit2.reporter) !== null && _ref95 !== void 0 ? _ref95 : 'v1'; -1 27641 setFrameSpec(partialResults); -1 27642 var results = merge_results_default(partialResults); -1 27643 results = axe._audit.after(results, options); -1 27644 results.forEach(publish_metadata_default); -1 27645 results = results.map(finalize_result_default); -1 27646 return createReport2(results, _extends({ -1 27647 environmentData: environmentData -1 27648 }, options)); -1 27649 } -1 27650 function setFrameSpec(partialResults) { -1 27651 var frameStack = []; -1 27652 var _iterator4 = _createForOfIteratorHelper(partialResults), _step4; -1 27653 try { -1 27654 for (_iterator4.s(); !(_step4 = _iterator4.n()).done; ) { -1 27655 var partialResult = _step4.value; -1 27656 var frameSpec = frameStack.shift(); -1 27657 if (!partialResult) { -1 27658 continue; -1 27659 } -1 27660 partialResult.frameSpec = frameSpec !== null && frameSpec !== void 0 ? frameSpec : null; -1 27661 var frameSpecs = getMergedFrameSpecs(partialResult); -1 27662 frameStack.unshift.apply(frameStack, _toConsumableArray(frameSpecs)); -1 27663 } -1 27664 } catch (err) { -1 27665 _iterator4.e(err); -1 27666 } finally { -1 27667 _iterator4.f(); -1 27668 } -1 27669 } -1 27670 function getMergedFrameSpecs(_ref96) { -1 27671 var childFrameSpecs = _ref96.frames, parentFrameSpec = _ref96.frameSpec; -1 27672 if (!parentFrameSpec) { -1 27673 return childFrameSpecs; -1 27674 } -1 27675 return childFrameSpecs.map(function(childFrameSpec) { -1 27676 return dq_element_default.mergeSpecs(childFrameSpec, parentFrameSpec); -1 27677 }); -1 27678 } -1 27679 function createReport2(results, options) { -1 27680 return new Promise(function(resolve) { -1 27681 var reporter5 = getReporter(options.reporter); -1 27682 reporter5(results, options, resolve); 53286 27683 });53287 -1 return p;53288 27684 }53289 -1 var run_default = run4;53290 27685 function setup(node) { 53291 27686 if (axe._tree) { 53292 27687 throw new Error('Axe is already setup. Call `axe.teardown()` before calling `axe.setup` again.'); @@ -53302,14 +27697,10 @@ module.exports = { 53302 27697 callback = options; 53303 27698 options = {}; 53304 27699 }53305 -1 var out = process_aggregate_default(results, options);53306 -1 callback(_extends({}, get_environment_data_default(), {53307 -1 toolOptions: options,53308 -1 violations: out.violations,53309 -1 passes: out.passes,53310 -1 incomplete: out.incomplete,53311 -1 inapplicable: out.inapplicable53312 -1 }));-1 27700 var _options2 = options, environmentData = _options2.environmentData, toolOptions = _objectWithoutProperties(_options2, _excluded11); -1 27701 callback(_extends({}, _getEnvironmentData(environmentData), { -1 27702 toolOptions: toolOptions -1 27703 }, process_aggregate_default(results, options))); 53313 27704 }; 53314 27705 var na_default = naReporter; 53315 27706 var noPassesReporter = function noPassesReporter(results, options, callback) { @@ -53317,11 +27708,12 @@ module.exports = { 53317 27708 callback = options; 53318 27709 options = {}; 53319 27710 } -1 27711 var _options3 = options, environmentData = _options3.environmentData, toolOptions = _objectWithoutProperties(_options3, _excluded12); 53320 27712 options.resultTypes = [ 'violations' ];53321 -1 var out = process_aggregate_default(results, options);53322 -1 callback(_extends({}, get_environment_data_default(), {53323 -1 toolOptions: options,53324 -1 violations: out.violations-1 27713 var _process_aggregate_de = process_aggregate_default(results, options), violations = _process_aggregate_de.violations; -1 27714 callback(_extends({}, _getEnvironmentData(environmentData), { -1 27715 toolOptions: toolOptions, -1 27716 violations: violations 53325 27717 })); 53326 27718 }; 53327 27719 var no_passes_default = noPassesReporter; @@ -53336,13 +27728,16 @@ module.exports = { 53336 27728 var transformedResults = results.map(function(result) { 53337 27729 var transformedResult = _extends({}, result); 53338 27730 var types = [ 'passes', 'violations', 'incomplete', 'inapplicable' ];53339 -1 for (var _i29 = 0, _types = types; _i29 < _types.length; _i29++) {53340 -1 var type = _types[_i29];-1 27731 for (var _i31 = 0, _types = types; _i31 < _types.length; _i31++) { -1 27732 var type = _types[_i31]; 53341 27733 if (transformedResult[type] && Array.isArray(transformedResult[type])) {53342 -1 transformedResult[type] = transformedResult[type].map(function(typeResult) {53343 -1 return _extends({}, typeResult, {53344 -1 node: typeResult.node.toJSON()53345 -1 });-1 27734 transformedResult[type] = transformedResult[type].map(function(_ref97) { -1 27735 var _node; -1 27736 var node = _ref97.node, typeResult = _objectWithoutProperties(_ref97, _excluded13); -1 27737 node = typeof ((_node = node) === null || _node === void 0 ? void 0 : _node.toJSON) === 'function' ? node.toJSON() : node; -1 27738 return _extends({ -1 27739 node: node -1 27740 }, typeResult); 53346 27741 }); 53347 27742 } 53348 27743 } @@ -53356,14 +27751,14 @@ module.exports = { 53356 27751 callback = options; 53357 27752 options = {}; 53358 27753 }53359 -1 function rawCallback(raw3) {53360 -1 var env = get_environment_data_default();-1 27754 var _options4 = options, environmentData = _options4.environmentData, toolOptions = _objectWithoutProperties(_options4, _excluded14); -1 27755 raw_default(results, toolOptions, function(raw3) { -1 27756 var env = _getEnvironmentData(environmentData); 53361 27757 callback({ 53362 27758 raw: raw3, 53363 27759 env: env 53364 27760 });53365 -1 }53366 -1 raw_default(results, options, rawCallback);-1 27761 }); 53367 27762 }; 53368 27763 var raw_env_default = rawEnvReporter; 53369 27764 var v1Reporter = function v1Reporter(results, options, callback) { @@ -53371,6 +27766,7 @@ module.exports = { 53371 27766 callback = options; 53372 27767 options = {}; 53373 27768 } -1 27769 var _options5 = options, environmentData = _options5.environmentData, toolOptions = _objectWithoutProperties(_options5, _excluded15); 53374 27770 var out = process_aggregate_default(results, options); 53375 27771 var addFailureSummaries = function addFailureSummaries(result) { 53376 27772 result.nodes.forEach(function(nodeResult) { @@ -53379,13 +27775,9 @@ module.exports = { 53379 27775 }; 53380 27776 out.incomplete.forEach(addFailureSummaries); 53381 27777 out.violations.forEach(addFailureSummaries);53382 -1 callback(_extends({}, get_environment_data_default(), {53383 -1 toolOptions: options,53384 -1 violations: out.violations,53385 -1 passes: out.passes,53386 -1 incomplete: out.incomplete,53387 -1 inapplicable: out.inapplicable53388 -1 }));-1 27778 callback(_extends({}, _getEnvironmentData(environmentData), { -1 27779 toolOptions: toolOptions -1 27780 }, out)); 53389 27781 }; 53390 27782 var v1_default = v1Reporter; 53391 27783 var v2Reporter = function v2Reporter(results, options, callback) { @@ -53393,14 +27785,11 @@ module.exports = { 53393 27785 callback = options; 53394 27786 options = {}; 53395 27787 } -1 27788 var _options6 = options, environmentData = _options6.environmentData, toolOptions = _objectWithoutProperties(_options6, _excluded16); 53396 27789 var out = process_aggregate_default(results, options);53397 -1 callback(_extends({}, get_environment_data_default(), {53398 -1 toolOptions: options,53399 -1 violations: out.violations,53400 -1 passes: out.passes,53401 -1 incomplete: out.incomplete,53402 -1 inapplicable: out.inapplicable53403 -1 }));-1 27790 callback(_extends({}, _getEnvironmentData(environmentData), { -1 27791 toolOptions: toolOptions -1 27792 }, out)); 53404 27793 }; 53405 27794 var v2_default = v2Reporter; 53406 27795 axe.constants = constants_default; @@ -53414,11 +27803,14 @@ module.exports = { 53414 27803 Audit: audit_default, 53415 27804 CheckResult: check_result_default, 53416 27805 Check: check_default,53417 -1 Context: context_default,-1 27806 Context: Context, 53418 27807 RuleResult: rule_result_default, 53419 27808 Rule: rule_default, 53420 27809 metadataFunctionMap: metadata_function_map_default 53421 27810 }; -1 27811 axe._thisWillBeDeletedDoNotUse['public'] = { -1 27812 reporters: reporters -1 27813 }; 53422 27814 axe.imports = imports_exports; 53423 27815 axe.cleanup = cleanup_default; 53424 27816 axe.configure = configure_default; @@ -53433,9 +27825,11 @@ module.exports = { 53433 27825 axe.reset = reset_default; 53434 27826 axe._runRules = run_rules_default; 53435 27827 axe.runVirtualRule = run_virtual_rule_default;53436 -1 axe.run = run_default;-1 27828 axe.run = run4; 53437 27829 axe.setup = setup_default; 53438 27830 axe.teardown = teardown_default; -1 27831 axe.runPartial = runPartial; -1 27832 axe.finishRun = finishRun; 53439 27833 axe.commons = commons_exports; 53440 27834 axe.utils = utils_exports; 53441 27835 axe.addReporter('na', na_default); @@ -53479,8 +27873,8 @@ module.exports = { 53479 27873 help: 'aria-hidden=\'true\' must not be present on the document body' 53480 27874 }, 53481 27875 'aria-hidden-focus': {53482 -1 description: 'Ensures aria-hidden elements do not contain focusable elements',53483 -1 help: 'ARIA hidden element must not contain focusable elements'-1 27876 description: 'Ensures aria-hidden elements are not focusable nor contain focusable elements', -1 27877 help: 'ARIA hidden element must not be focusable or contain focusable elements' 53484 27878 }, 53485 27879 'aria-input-field-name': { 53486 27880 description: 'Ensures every ARIA input field has an accessible name', @@ -53508,7 +27902,7 @@ module.exports = { 53508 27902 }, 53509 27903 'aria-roledescription': { 53510 27904 description: 'Ensure aria-roledescription is only used on elements with an implicit or explicit role',53511 -1 help: 'Use aria-roledescription on elements with a semantic role'-1 27905 help: 'aria-roledescription must be on elements with a semantic role' 53512 27906 }, 53513 27907 'aria-roles': { 53514 27908 description: 'Ensures all elements with a role attribute use a valid value', @@ -53520,7 +27914,7 @@ module.exports = { 53520 27914 }, 53521 27915 'aria-toggle-field-name': { 53522 27916 description: 'Ensures every ARIA toggle field has an accessible name',53523 -1 help: 'ARIA toggle fields have an accessible name'-1 27917 help: 'ARIA toggle fields must have an accessible name' 53524 27918 }, 53525 27919 'aria-tooltip-name': { 53526 27920 description: 'Ensures every ARIA tooltip node has an accessible name', @@ -53562,13 +27956,17 @@ module.exports = { 53562 27956 description: 'Ensures each page has at least one mechanism for a user to bypass navigation and jump straight to the content', 53563 27957 help: 'Page must have means to bypass repeated blocks' 53564 27958 }, -1 27959 'color-contrast-enhanced': { -1 27960 description: 'Ensures the contrast between foreground and background colors meets WCAG 2 AAA contrast ratio thresholds', -1 27961 help: 'Elements must have sufficient color contrast' -1 27962 }, 53565 27963 'color-contrast': { 53566 27964 description: 'Ensures the contrast between foreground and background colors meets WCAG 2 AA contrast ratio thresholds', 53567 27965 help: 'Elements must have sufficient color contrast' 53568 27966 }, 53569 27967 'css-orientation-lock': { 53570 27968 description: 'Ensures content is not locked to any specific display orientation, and the content is operable in all display orientations',53571 -1 help: 'CSS Media queries are not used to lock display orientation'-1 27969 help: 'CSS Media queries must not lock display orientation' 53572 27970 }, 53573 27971 'definition-list': { 53574 27972 description: 'Ensures <dl> elements are structured correctly', @@ -53603,8 +28001,8 @@ module.exports = { 53603 28001 help: 'Table header text must not be empty' 53604 28002 }, 53605 28003 'focus-order-semantics': {53606 -1 description: 'Ensures elements in the focus order have an appropriate role',53607 -1 help: 'Elements in the focus order need a role appropriate for interactive content'-1 28004 description: 'Ensures elements in the focus order have a role appropriate for interactive content', -1 28005 help: 'Elements in the focus order should have an appropriate role' 53608 28006 }, 53609 28007 'form-field-multiple-labels': { 53610 28008 description: 'Ensures form field does not have multiple label elements', @@ -53632,7 +28030,7 @@ module.exports = { 53632 28030 }, 53633 28031 'hidden-content': { 53634 28032 description: 'Informs users about hidden content.',53635 -1 help: 'Hidden content on the page cannot be analyzed'-1 28033 help: 'Hidden content on the page should be analyzed' 53636 28034 }, 53637 28035 'html-has-lang': { 53638 28036 description: 'Ensures every HTML document has a lang attribute', @@ -53648,7 +28046,7 @@ module.exports = { 53648 28046 }, 53649 28047 'identical-links-same-purpose': { 53650 28048 description: 'Ensure that links with the same accessible name serve a similar purpose',53651 -1 help: 'Links with the same name have a similar purpose'-1 28049 help: 'Links with the same name must have a similar purpose' 53652 28050 }, 53653 28051 'image-alt': { 53654 28052 description: 'Ensures <img> elements have alternate text or a role of none or presentation', @@ -53671,7 +28069,7 @@ module.exports = { 53671 28069 help: 'Elements must have their visible text as part of their accessible name' 53672 28070 }, 53673 28071 'label-title-only': {53674 -1 description: 'Ensures that every form element is not solely labeled using the title or aria-describedby attributes',-1 28072 description: 'Ensures that every form element has a visible label and is not solely labeled using hidden labels, or the title or aria-describedby attributes', 53675 28073 help: 'Form elements should have a visible label' 53676 28074 }, 53677 28075 label: { @@ -53715,8 +28113,8 @@ module.exports = { 53715 28113 description: 'Landmarks should have a unique role or role/label/title (i.e. accessible name) combination' 53716 28114 }, 53717 28115 'link-in-text-block': {53718 -1 description: 'Links can be distinguished without relying on color',53719 -1 help: 'Links must be distinguished from surrounding text in a way that does not rely on color'-1 28116 description: 'Ensure links are distinguished from surrounding text in a way that does not rely on color', -1 28117 help: 'Links must be distinguishable without relying on color' 53720 28118 }, 53721 28119 'link-name': { 53722 28120 description: 'Ensures links have discernible text', @@ -53747,20 +28145,20 @@ module.exports = { 53747 28145 help: 'Zooming and scaling should not be disabled' 53748 28146 }, 53749 28147 'nested-interactive': {53750 -1 description: 'Nested interactive controls are not announced by screen readers',53751 -1 help: 'Ensure interactive controls are not nested'-1 28148 description: 'Ensures interactive controls are not nested as they are not always announced by screen readers or can cause focus problems for assistive technologies', -1 28149 help: 'Interactive controls must not be nested' 53752 28150 }, 53753 28151 'no-autoplay-audio': { 53754 28152 description: 'Ensures <video> or <audio> elements do not autoplay audio for more than 3 seconds without a control mechanism to stop or mute the audio',53755 -1 help: '<video> or <audio> elements do not autoplay audio'-1 28153 help: '<video> or <audio> elements must not play automatically' 53756 28154 }, 53757 28155 'object-alt': { 53758 28156 description: 'Ensures <object> elements have alternate text', 53759 28157 help: '<object> elements must have alternate text' 53760 28158 }, 53761 28159 'p-as-heading': {53762 -1 description: 'Ensure p elements are not used to style headings',53763 -1 help: 'Bold, italic text and font-size are not used to style p elements as a heading'-1 28160 description: 'Ensure bold, italic text and font-size is not used to style <p> elements as a heading', -1 28161 help: 'Styled <p> elements must not be used as headings' 53764 28162 }, 53765 28163 'page-has-heading-one': { 53766 28164 description: 'Ensure that the page, or at least one of its frames contains a level-one heading', @@ -53776,15 +28174,15 @@ module.exports = { 53776 28174 }, 53777 28175 'role-img-alt': { 53778 28176 description: 'Ensures [role=\'img\'] elements have alternate text',53779 -1 help: '[role=\'img\'] elements have an alternative text'-1 28177 help: '[role=\'img\'] elements must have an alternative text' 53780 28178 }, 53781 28179 'scope-attr-valid': { 53782 28180 description: 'Ensures the scope attribute is used correctly on tables', 53783 28181 help: 'scope attribute should be used correctly' 53784 28182 }, 53785 28183 'scrollable-region-focusable': {53786 -1 description: 'Elements that have scrollable content must be accessible by keyboard',53787 -1 help: 'Ensure that scrollable region has keyboard access'-1 28184 description: 'Ensure elements that have scrollable content are accessible by keyboard', -1 28185 help: 'Scrollable region must have keyboard access' 53788 28186 }, 53789 28187 'select-name': { 53790 28188 description: 'Ensures select element has an accessible name', @@ -53799,32 +28197,32 @@ module.exports = { 53799 28197 help: 'The skip-link target should exist and be focusable' 53800 28198 }, 53801 28199 'svg-img-alt': {53802 -1 description: 'Ensures svg elements with an img, graphics-document or graphics-symbol role have an accessible text',53803 -1 help: 'svg elements with an img role have an alternative text'-1 28200 description: 'Ensures <svg> elements with an img, graphics-document or graphics-symbol role have an accessible text', -1 28201 help: '<svg> elements with an img role must have an alternative text' 53804 28202 }, 53805 28203 tabindex: { 53806 28204 description: 'Ensures tabindex attribute values are not greater than 0', 53807 28205 help: 'Elements should not have tabindex greater than zero' 53808 28206 }, 53809 28207 'table-duplicate-name': {53810 -1 description: 'Ensure that tables do not have the same summary and caption',53811 -1 help: 'The <caption> element should not contain the same text as the summary attribute'-1 28208 description: 'Ensure the <caption> element does not contain the same text as the summary attribute', -1 28209 help: 'tables should not have the same summary and caption' 53812 28210 }, 53813 28211 'table-fake-caption': { 53814 28212 description: 'Ensure that tables with a caption use the <caption> element.', 53815 28213 help: 'Data or header cells must not be used to give caption to a data table.' 53816 28214 }, 53817 28215 'td-has-header': {53818 -1 description: 'Ensure that each non-empty data cell in a large table has one or more table headers',53819 -1 help: 'All non-empty td element in table larger than 3 by 3 must have an associated table header'-1 28216 description: 'Ensure that each non-empty data cell in a <table> larger than 3 by 3 has one or more table headers', -1 28217 help: 'Non-empty <td> elements in larger <table> must have an associated table header' 53820 28218 }, 53821 28219 'td-headers-attr': {53822 -1 description: 'Ensure that each cell in a table using the headers refers to another cell in that table',53823 -1 help: 'All cells in a table element that use the headers attribute must only refer to other cells of that same table'-1 28220 description: 'Ensure that each cell in a table that uses the headers attribute refers only to other cells in that table', -1 28221 help: 'Table cells that use the headers attribute must only refer to cells in the same table' 53824 28222 }, 53825 28223 'th-has-data-cells': {53826 -1 description: 'Ensure that each table header in a data table refers to data cells',53827 -1 help: 'All th elements and elements with role=columnheader/rowheader must have data cells they describe'-1 28224 description: 'Ensure that <th> elements and elements with role=columnheader/rowheader have data cells they describe', -1 28225 help: 'Table headers in a data table must refer to data cells' 53828 28226 }, 53829 28227 'valid-lang': { 53830 28228 description: 'Ensures lang attributes have valid values', @@ -53853,7 +28251,8 @@ module.exports = { 53853 28251 fail: { 53854 28252 singular: 'ARIA attribute is not allowed: ${data.values}', 53855 28253 plural: 'ARIA attributes are not allowed: ${data.values}'53856 -1 }-1 28254 }, -1 28255 incomplete: 'Check that there is no problem if the ARIA attribute is ignored on this element: ${data.values}' 53857 28256 } 53858 28257 }, 53859 28258 'aria-allowed-role': { @@ -53876,11 +28275,13 @@ module.exports = { 53876 28275 pass: 'aria-errormessage exists and references elements visible to screen readers that use a supported aria-errormessage technique', 53877 28276 fail: { 53878 28277 singular: 'aria-errormessage value `${data.values}` must use a technique to announce the message (e.g., aria-live, aria-describedby, role=alert, etc.)',53879 -1 plural: 'aria-errormessage values `${data.values}` must use a technique to announce the message (e.g., aria-live, aria-describedby, role=alert, etc.)'-1 28278 plural: 'aria-errormessage values `${data.values}` must use a technique to announce the message (e.g., aria-live, aria-describedby, role=alert, etc.)', -1 28279 hidden: 'aria-errormessage value `${data.values}` cannot reference a hidden element' 53880 28280 }, 53881 28281 incomplete: { 53882 28282 singular: 'ensure aria-errormessage value `${data.values}` references an existing element',53883 -1 plural: 'ensure aria-errormessage values `${data.values}` reference existing elements'-1 28283 plural: 'ensure aria-errormessage values `${data.values}` reference existing elements', -1 28284 idrefs: 'unable to determine if aria-errormessage element exists on the page: ${data.values}' 53884 28285 } 53885 28286 } 53886 28287 }, @@ -53891,12 +28292,29 @@ module.exports = { 53891 28292 fail: 'aria-hidden=true should not be present on the document body' 53892 28293 } 53893 28294 }, -1 28295 'aria-level': { -1 28296 impact: 'serious', -1 28297 messages: { -1 28298 pass: 'aria-level values are valid', -1 28299 incomplete: 'aria-level values greater than 6 are not supported in all screenreader and browser combinations' -1 28300 } -1 28301 }, 53894 28302 'aria-prohibited-attr': { 53895 28303 impact: 'serious', 53896 28304 messages: { 53897 28305 pass: 'ARIA attribute is allowed',53898 -1 fail: 'ARIA attribute cannot be used, add a role attribute or use a different element: ${data.values}',53899 -1 incomplete: 'ARIA attribute is not well supported on the element and the text content will be used instead: ${data.values}'-1 28306 fail: { -1 28307 hasRolePlural: '${data.prohibited} attributes cannot be used with role "${data.role}".', -1 28308 hasRoleSingular: '${data.prohibited} attribute cannot be used with role "${data.role}".', -1 28309 noRolePlural: '${data.prohibited} attributes cannot be used on a ${data.nodeName} with no valid role attribute.', -1 28310 noRoleSingular: '${data.prohibited} attribute cannot be used on a ${data.nodeName} with no valid role attribute.' -1 28311 }, -1 28312 incomplete: { -1 28313 hasRoleSingular: '${data.prohibited} attribute is not well supported with role "${data.role}".', -1 28314 hasRolePlural: '${data.prohibited} attributes are not well supported with role "${data.role}".', -1 28315 noRoleSingular: '${data.prohibited} attribute is not well supported on a ${data.nodeName} with no valid role attribute.', -1 28316 noRolePlural: '${data.prohibited} attributes are not well supported on a ${data.nodeName} with no valid role attribute.' -1 28317 } 53900 28318 } 53901 28319 }, 53902 28320 'aria-required-attr': { @@ -53958,7 +28376,9 @@ module.exports = { 53958 28376 }, 53959 28377 incomplete: { 53960 28378 noId: 'ARIA attribute element ID does not exist on the page: ${data.needsReview}',53961 -1 ariaCurrent: 'ARIA attribute value is invalid and will be treated as "aria-current=true": ${data.needsReview}'-1 28379 noIdShadow: 'ARIA attribute element ID does not exist on the page or is a descendant of a different shadow DOM tree: ${data.needsReview}', -1 28380 ariaCurrent: 'ARIA attribute value is invalid and will be treated as "aria-current=true": ${data.needsReview}', -1 28381 idrefs: 'Unable to determine if ARIA attribute element ID exists on the page: ${data.needsReview}' 53962 28382 } 53963 28383 } 53964 28384 }, @@ -53972,11 +28392,19 @@ module.exports = { 53972 28392 } 53973 28393 } 53974 28394 }, -1 28395 deprecatedrole: { -1 28396 impact: 'minor', -1 28397 messages: { -1 28398 pass: 'ARIA role is not deprecated', -1 28399 fail: 'The role used is deprecated: ${data}' -1 28400 } -1 28401 }, 53975 28402 fallbackrole: { 53976 28403 impact: 'serious', 53977 28404 messages: { 53978 28405 pass: 'Only one role value used',53979 -1 fail: 'Use only one role value, since fallback roles are not supported in older browsers'-1 28406 fail: 'Use only one role value, since fallback roles are not supported in older browsers', -1 28407 incomplete: 'Use only role \'presentation\' or \'none\' since they are synonymous.' 53980 28408 } 53981 28409 }, 53982 28410 'has-global-aria-attribute': { @@ -54034,11 +28462,44 @@ module.exports = { 54034 28462 fail: 'Element has invalid semantics for an element in the focus order.' 54035 28463 } 54036 28464 },54037 -1 'color-contrast': {-1 28465 'color-contrast-enhanced': { 54038 28466 impact: 'serious', 54039 28467 messages: { 54040 28468 pass: 'Element has sufficient color contrast of ${data.contrastRatio}',54041 -1 fail: 'Element has insufficient color contrast of ${data.contrastRatio} (foreground color: ${data.fgColor}, background color: ${data.bgColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}',-1 28469 fail: { -1 28470 default: 'Element has insufficient color contrast of ${data.contrastRatio} (foreground color: ${data.fgColor}, background color: ${data.bgColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}', -1 28471 fgOnShadowColor: 'Element has insufficient color contrast of ${data.contrastRatio} between the foreground and shadow color (foreground color: ${data.fgColor}, text-shadow color: ${data.shadowColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}', -1 28472 shadowOnBgColor: 'Element has insufficient color contrast of ${data.contrastRatio} between the shadow color and background color (text-shadow color: ${data.shadowColor}, background color: ${data.bgColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}' -1 28473 }, -1 28474 incomplete: { -1 28475 default: 'Unable to determine contrast ratio', -1 28476 bgImage: 'Element\'s background color could not be determined due to a background image', -1 28477 bgGradient: 'Element\'s background color could not be determined due to a background gradient', -1 28478 imgNode: 'Element\'s background color could not be determined because element contains an image node', -1 28479 bgOverlap: 'Element\'s background color could not be determined because it is overlapped by another element', -1 28480 fgAlpha: 'Element\'s foreground color could not be determined because of alpha transparency', -1 28481 elmPartiallyObscured: 'Element\'s background color could not be determined because it\'s partially obscured by another element', -1 28482 elmPartiallyObscuring: 'Element\'s background color could not be determined because it partially overlaps other elements', -1 28483 outsideViewport: 'Element\'s background color could not be determined because it\'s outside the viewport', -1 28484 equalRatio: 'Element has a 1:1 contrast ratio with the background', -1 28485 shortTextContent: 'Element content is too short to determine if it is actual text content', -1 28486 nonBmp: 'Element content contains only non-text characters', -1 28487 pseudoContent: 'Element\'s background color could not be determined due to a pseudo element' -1 28488 } -1 28489 } -1 28490 }, -1 28491 'color-contrast': { -1 28492 impact: 'serious', -1 28493 messages: { -1 28494 pass: { -1 28495 default: 'Element has sufficient color contrast of ${data.contrastRatio}', -1 28496 hidden: 'Element is hidden' -1 28497 }, -1 28498 fail: { -1 28499 default: 'Element has insufficient color contrast of ${data.contrastRatio} (foreground color: ${data.fgColor}, background color: ${data.bgColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}', -1 28500 fgOnShadowColor: 'Element has insufficient color contrast of ${data.contrastRatio} between the foreground and shadow color (foreground color: ${data.fgColor}, text-shadow color: ${data.shadowColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}', -1 28501 shadowOnBgColor: 'Element has insufficient color contrast of ${data.contrastRatio} between the shadow color and background color (text-shadow color: ${data.shadowColor}, background color: ${data.bgColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}' -1 28502 }, 54042 28503 incomplete: { 54043 28504 default: 'Unable to determine contrast ratio', 54044 28505 bgImage: 'Element\'s background color could not be determined due to a background image', @@ -54103,6 +28564,7 @@ module.exports = { 54103 28564 impact: 'serious', 54104 28565 messages: { 54105 28566 pass: 'No focusable elements contained within element', -1 28567 incomplete: 'Check if the focusable elements immediately move the focus indicator', 54106 28568 fail: 'Focusable content should be disabled or be removed from the DOM' 54107 28569 } 54108 28570 }, @@ -54132,6 +28594,7 @@ module.exports = { 54132 28594 impact: 'serious', 54133 28595 messages: { 54134 28596 pass: 'No focusable elements contained within element', -1 28597 incomplete: 'Check if the focusable elements immediately move the focus indicator', 54135 28598 fail: 'Focusable content should have tabindex=\'-1\' or be removed from the DOM' 54136 28599 } 54137 28600 }, @@ -54154,7 +28617,10 @@ module.exports = { 54154 28617 impact: 'serious', 54155 28618 messages: { 54156 28619 pass: 'Element does not have focusable descendants',54157 -1 fail: 'Element has focusable descendants',-1 28620 fail: { -1 28621 default: 'Element has focusable descendants', -1 28622 notHidden: 'Using a negative tabindex on an element inside an interactive control does not prevent assistive technologies from focusing the element (even with \'aria-hidden=true\')' -1 28623 }, 54158 28624 incomplete: 'Could not determine if element has descendants' 54159 28625 } 54160 28626 }, @@ -54430,7 +28896,8 @@ module.exports = { 54430 28896 impact: 'serious', 54431 28897 messages: { 54432 28898 pass: '<p> elements are not styled as headings',54433 -1 fail: 'Heading elements should be used instead of styled p elements'-1 28899 fail: 'Heading elements should be used instead of styled <p> elements', -1 28900 incomplete: 'Unable to determine if <p> elements are styled as headings' 54434 28901 } 54435 28902 }, 54436 28903 region: { @@ -54722,7 +29189,7 @@ module.exports = { 54722 29189 } 54723 29190 } 54724 29191 },54725 -1 incompleteFallbackMessage: {}-1 29192 incompleteFallbackMessage: 'axe couldn\'t tell the reason. Time to break out the element inspector!' 54726 29193 }, 54727 29194 rules: [ { 54728 29195 id: 'accesskeys', @@ -54737,6 +29204,7 @@ module.exports = { 54737 29204 selector: 'map area[href]', 54738 29205 excludeHidden: false, 54739 29206 tags: [ 'cat.text-alternatives', 'wcag2a', 'wcag111', 'wcag244', 'wcag412', 'section508', 'section508.22.a', 'ACT' ], -1 29207 actIds: [ 'c487ae' ], 54740 29208 all: [], 54741 29209 any: [ { 54742 29210 options: { @@ -54754,8 +29222,14 @@ module.exports = { 54754 29222 id: 'aria-allowed-attr', 54755 29223 matches: 'aria-allowed-attr-matches', 54756 29224 tags: [ 'cat.aria', 'wcag2a', 'wcag412' ], -1 29225 actIds: [ '5c01ea' ], 54757 29226 all: [],54758 -1 any: [ 'aria-allowed-attr' ],-1 29227 any: [ { -1 29228 options: { -1 29229 validTreeRowAttrs: [ 'aria-posinset', 'aria-setsize', 'aria-expanded', 'aria-level' ] -1 29230 }, -1 29231 id: 'aria-allowed-attr' -1 29232 } ], 54759 29233 none: [ 'aria-unsupported-attr', { 54760 29234 options: { 54761 29235 elementsAllowedAriaLabel: [ 'applet', 'input' ] @@ -54782,6 +29256,7 @@ module.exports = { 54782 29256 selector: '[role="link"], [role="button"], [role="menuitem"]', 54783 29257 matches: 'no-naming-method-matches', 54784 29258 tags: [ 'cat.aria', 'wcag2a', 'wcag412' ], -1 29259 actIds: [ '97a4e1' ], 54785 29260 all: [], 54786 29261 any: [ 'has-visible-text', 'aria-label', 'aria-labelledby', { 54787 29262 options: { @@ -54818,6 +29293,7 @@ module.exports = { 54818 29293 matches: 'aria-hidden-focus-matches', 54819 29294 excludeHidden: false, 54820 29295 tags: [ 'cat.name-role-value', 'wcag2a', 'wcag412', 'wcag131' ], -1 29296 actIds: [ '6cfa84' ], 54821 29297 all: [ 'focusable-modal-open', 'focusable-disabled', 'focusable-not-tabbable' ], 54822 29298 any: [], 54823 29299 none: [] @@ -54826,6 +29302,7 @@ module.exports = { 54826 29302 selector: '[role="combobox"], [role="listbox"], [role="searchbox"], [role="slider"], [role="spinbutton"], [role="textbox"]', 54827 29303 matches: 'no-naming-method-matches', 54828 29304 tags: [ 'cat.aria', 'wcag2a', 'wcag412', 'ACT' ], -1 29305 actIds: [ 'e086e5' ], 54829 29306 all: [], 54830 29307 any: [ 'aria-label', 'aria-labelledby', { 54831 29308 options: { @@ -54872,6 +29349,7 @@ module.exports = { 54872 29349 selector: '[role]', 54873 29350 matches: 'aria-required-children-matches', 54874 29351 tags: [ 'cat.aria', 'wcag2a', 'wcag131' ], -1 29352 actIds: [ 'ff89c9' ], 54875 29353 all: [], 54876 29354 any: [ { 54877 29355 options: { @@ -54885,6 +29363,7 @@ module.exports = { 54885 29363 selector: '[role]', 54886 29364 matches: 'aria-required-parent-matches', 54887 29365 tags: [ 'cat.aria', 'wcag2a', 'wcag131' ], -1 29366 actIds: [ 'bc4a75', 'ff89c9' ], 54888 29367 all: [], 54889 29368 any: [ { 54890 29369 options: { @@ -54912,7 +29391,7 @@ module.exports = { 54912 29391 tags: [ 'cat.aria', 'wcag2a', 'wcag412' ], 54913 29392 all: [], 54914 29393 any: [],54915 -1 none: [ 'fallbackrole', 'invalidrole', 'abstractrole', 'unsupportedrole' ]-1 29394 none: [ 'fallbackrole', 'invalidrole', 'abstractrole', 'unsupportedrole', 'deprecatedrole' ] 54916 29395 }, { 54917 29396 id: 'aria-text', 54918 29397 selector: '[role=text]', @@ -54963,10 +29442,11 @@ module.exports = { 54963 29442 id: 'aria-valid-attr-value', 54964 29443 matches: 'aria-has-attr-matches', 54965 29444 tags: [ 'cat.aria', 'wcag2a', 'wcag412' ], -1 29445 actIds: [ '5c01ea', 'c487ae' ], 54966 29446 all: [ { 54967 29447 options: [], 54968 29448 id: 'aria-valid-attr-value'54969 -1 }, 'aria-errormessage' ],-1 29449 }, 'aria-errormessage', 'aria-level' ], 54970 29450 any: [], 54971 29451 none: [] 54972 29452 }, { @@ -54985,6 +29465,7 @@ module.exports = { 54985 29465 enabled: false, 54986 29466 excludeHidden: false, 54987 29467 tags: [ 'cat.time-and-media', 'wcag2a', 'wcag121', 'section508', 'section508.22.a' ], -1 29468 actIds: [ 'c3232f', 'e7aa44' ], 54988 29469 all: [], 54989 29470 any: [], 54990 29471 none: [ 'caption' ] @@ -54992,7 +29473,13 @@ module.exports = { 54992 29473 id: 'autocomplete-valid', 54993 29474 matches: 'autocomplete-matches', 54994 29475 tags: [ 'cat.forms', 'wcag21aa', 'wcag135' ],54995 -1 all: [ 'autocomplete-valid', 'autocomplete-appropriate' ],-1 29476 actIds: [ '73f2c2' ], -1 29477 all: [ { -1 29478 options: { -1 29479 stateTerms: [ 'none', 'false', 'true', 'disabled', 'enabled', 'undefined', 'null' ] -1 29480 }, -1 29481 id: 'autocomplete-valid' -1 29482 } ], 54996 29483 any: [], 54997 29484 none: [] 54998 29485 }, { @@ -55020,6 +29507,7 @@ module.exports = { 55020 29507 selector: 'button', 55021 29508 matches: 'no-explicit-name-required-matches', 55022 29509 tags: [ 'cat.name-role-value', 'wcag2a', 'wcag412', 'section508', 'section508.22.a', 'ACT' ], -1 29510 actIds: [ '97a4e1', 'm6b1q3' ], 55023 29511 all: [], 55024 29512 any: [ 'button-has-visible-text', 'aria-label', 'aria-labelledby', { 55025 29513 options: { @@ -55049,6 +29537,35 @@ module.exports = { 55049 29537 } ], 55050 29538 none: [] 55051 29539 }, { -1 29540 id: 'color-contrast-enhanced', -1 29541 matches: 'color-contrast-matches', -1 29542 excludeHidden: false, -1 29543 enabled: false, -1 29544 tags: [ 'cat.color', 'wcag2aaa', 'wcag146' ], -1 29545 all: [], -1 29546 any: [ { -1 29547 options: { -1 29548 ignoreUnicode: true, -1 29549 ignoreLength: false, -1 29550 ignorePseudo: false, -1 29551 boldValue: 700, -1 29552 boldTextPt: 14, -1 29553 largeTextPt: 18, -1 29554 contrastRatio: { -1 29555 normal: { -1 29556 expected: 7 -1 29557 }, -1 29558 large: { -1 29559 expected: 4.5 -1 29560 } -1 29561 }, -1 29562 pseudoSizeThreshold: .25, -1 29563 shadowOutlineEmMax: .1 -1 29564 }, -1 29565 id: 'color-contrast-enhanced' -1 29566 } ], -1 29567 none: [] -1 29568 }, { 55052 29569 id: 'color-contrast', 55053 29570 matches: 'color-contrast-matches', 55054 29571 excludeHidden: false, @@ -55058,6 +29575,7 @@ module.exports = { 55058 29575 options: { 55059 29576 ignoreUnicode: true, 55060 29577 ignoreLength: false, -1 29578 ignorePseudo: false, 55061 29579 boldValue: 700, 55062 29580 boldTextPt: 14, 55063 29581 largeTextPt: 18, @@ -55069,7 +29587,8 @@ module.exports = { 55069 29587 expected: 3 55070 29588 } 55071 29589 },55072 -1 shadowOutlineEmMax: .1-1 29590 pseudoSizeThreshold: .25, -1 29591 shadowOutlineEmMax: .2 55073 29592 }, 55074 29593 id: 'color-contrast' 55075 29594 } ], @@ -55078,6 +29597,7 @@ module.exports = { 55078 29597 id: 'css-orientation-lock', 55079 29598 selector: 'html', 55080 29599 tags: [ 'cat.structure', 'wcag134', 'wcag21aa', 'experimental' ], -1 29600 actIds: [ 'b33eff' ], 55081 29601 all: [ { 55082 29602 options: { 55083 29603 degreeThreshold: 2 @@ -55108,6 +29628,7 @@ module.exports = { 55108 29628 selector: 'html', 55109 29629 matches: 'is-initiator-matches', 55110 29630 tags: [ 'cat.text-alternatives', 'wcag2a', 'wcag242', 'ACT' ], -1 29631 actIds: [ '2779a5' ], 55111 29632 all: [], 55112 29633 any: [ 'doc-has-title' ], 55113 29634 none: [] @@ -55126,6 +29647,7 @@ module.exports = { 55126 29647 matches: 'duplicate-id-aria-matches', 55127 29648 excludeHidden: false, 55128 29649 tags: [ 'cat.parsing', 'wcag2a', 'wcag411' ], -1 29650 actIds: [ '3ea0c8' ], 55129 29651 all: [], 55130 29652 any: [ 'duplicate-id-aria' ], 55131 29653 none: [] @@ -55245,6 +29767,7 @@ module.exports = { 55245 29767 selector: 'html', 55246 29768 matches: 'is-initiator-matches', 55247 29769 tags: [ 'cat.language', 'wcag2a', 'wcag311', 'ACT' ], -1 29770 actIds: [ 'b5c3f8' ], 55248 29771 all: [], 55249 29772 any: [ { 55250 29773 options: { @@ -55257,6 +29780,7 @@ module.exports = { 55257 29780 id: 'html-lang-valid', 55258 29781 selector: 'html[lang], html[xml\\:lang]', 55259 29782 tags: [ 'cat.language', 'wcag2a', 'wcag311', 'ACT' ], -1 29783 actIds: [ 'bf051a' ], 55260 29784 all: [], 55261 29785 any: [], 55262 29786 none: [ { @@ -55270,6 +29794,7 @@ module.exports = { 55270 29794 selector: 'html[lang][xml\\:lang]', 55271 29795 matches: 'xml-lang-mismatch-matches', 55272 29796 tags: [ 'cat.language', 'wcag2a', 'wcag311', 'ACT' ], -1 29797 actIds: [ '5b7ae0' ], 55273 29798 all: [ 'xml-lang-mismatch' ], 55274 29799 any: [], 55275 29800 none: [] @@ -55278,7 +29803,8 @@ module.exports = { 55278 29803 selector: 'a[href], area[href], [role="link"]', 55279 29804 excludeHidden: false, 55280 29805 matches: 'identical-links-same-purpose-matches',55281 -1 tags: [ 'cat.semantics', 'wcag2aaa', 'wcag249', 'best-practice' ],-1 29806 tags: [ 'cat.semantics', 'wcag2aaa', 'wcag249' ], -1 29807 actIds: [ 'b20e66', 'fd3a94' ], 55282 29808 all: [ 'identical-links-same-purpose' ], 55283 29809 any: [], 55284 29810 none: [] @@ -55287,6 +29813,7 @@ module.exports = { 55287 29813 selector: 'img', 55288 29814 matches: 'no-explicit-name-required-matches', 55289 29815 tags: [ 'cat.text-alternatives', 'wcag2a', 'wcag111', 'section508', 'section508.22.a', 'ACT' ], -1 29816 actIds: [ '23a2a8' ], 55290 29817 all: [], 55291 29818 any: [ 'has-alt', 'aria-label', 'aria-labelledby', { 55292 29819 options: { @@ -55330,6 +29857,7 @@ module.exports = { 55330 29857 selector: 'input[type="image"]', 55331 29858 matches: 'no-explicit-name-required-matches', 55332 29859 tags: [ 'cat.text-alternatives', 'wcag2a', 'wcag111', 'section508', 'section508.22.a', 'ACT' ], -1 29860 actIds: [ '59796f' ], 55333 29861 all: [], 55334 29862 any: [ { 55335 29863 options: { @@ -55347,6 +29875,7 @@ module.exports = { 55347 29875 id: 'label-content-name-mismatch', 55348 29876 matches: 'label-content-name-mismatch-matches', 55349 29877 tags: [ 'cat.semantics', 'wcag21a', 'wcag253', 'experimental' ], -1 29878 actIds: [ '2ee8b8' ], 55350 29879 all: [], 55351 29880 any: [ { 55352 29881 options: { @@ -55369,6 +29898,7 @@ module.exports = { 55369 29898 selector: 'input, textarea', 55370 29899 matches: 'label-matches', 55371 29900 tags: [ 'cat.forms', 'wcag2a', 'wcag412', 'wcag131', 'section508', 'section508.22.n', 'ACT' ], -1 29901 actIds: [ 'e086e5', '307n5z' ], 55372 29902 all: [], 55373 29903 any: [ 'implicit-label', 'explicit-label', 'aria-label', 'aria-labelledby', { 55374 29904 options: { @@ -55483,6 +30013,7 @@ module.exports = { 55483 30013 id: 'link-name', 55484 30014 selector: 'a[href]', 55485 30015 tags: [ 'cat.name-role-value', 'wcag2a', 'wcag412', 'wcag244', 'section508', 'section508.22.a', 'ACT' ], -1 30016 actIds: [ 'c487ae' ], 55486 30017 all: [], 55487 30018 any: [ 'has-visible-text', 'aria-label', 'aria-labelledby', { 55488 30019 options: { @@ -55519,7 +30050,7 @@ module.exports = { 55519 30050 id: 'meta-refresh', 55520 30051 selector: 'meta[http-equiv="refresh"]', 55521 30052 excludeHidden: false,55522 -1 tags: [ 'cat.time-and-media', 'wcag2a', 'wcag2aaa', 'wcag221', 'wcag224', 'wcag325' ],-1 30053 tags: [ 'cat.time-and-media', 'wcag2a', 'wcag221', 'wcag224', 'wcag325' ], 55523 30054 all: [], 55524 30055 any: [ 'meta-refresh' ], 55525 30056 none: [] @@ -55544,6 +30075,7 @@ module.exports = { 55544 30075 matches: 'is-initiator-matches', 55545 30076 excludeHidden: false, 55546 30077 tags: [ 'cat.sensory-and-visual-cues', 'best-practice', 'ACT' ], -1 30078 actIds: [ 'b4f0c3' ], 55547 30079 all: [], 55548 30080 any: [ { 55549 30081 options: { @@ -55556,6 +30088,7 @@ module.exports = { 55556 30088 id: 'nested-interactive', 55557 30089 matches: 'nested-interactive-matches', 55558 30090 tags: [ 'cat.keyboard', 'wcag2a', 'wcag412' ], -1 30091 actIds: [ '307n5z' ], 55559 30092 all: [], 55560 30093 any: [ 'no-focusable-content' ], 55561 30094 none: [] @@ -55565,6 +30098,7 @@ module.exports = { 55565 30098 selector: 'audio[autoplay], video[autoplay]', 55566 30099 matches: 'no-autoplay-audio-matches', 55567 30100 tags: [ 'cat.time-and-media', 'wcag2a', 'wcag142', 'experimental' ], -1 30101 actIds: [ '80f0bf' ], 55568 30102 preload: true, 55569 30103 all: [ { 55570 30104 options: { @@ -55579,6 +30113,7 @@ module.exports = { 55579 30113 selector: 'object', 55580 30114 matches: 'no-explicit-name-required-matches', 55581 30115 tags: [ 'cat.text-alternatives', 'wcag2a', 'wcag111', 'section508', 'section508.22.a' ], -1 30116 actIds: [ '8fc3b6' ], 55582 30117 all: [], 55583 30118 any: [ 'aria-label', 'aria-labelledby', { 55584 30119 options: { @@ -55605,7 +30140,9 @@ module.exports = { 55605 30140 size: 1.15 55606 30141 }, { 55607 30142 size: 1.455608 -1 } ]-1 30143 } ], -1 30144 passLength: 1, -1 30145 failLength: .5 55609 30146 }, 55610 30147 id: 'p-as-heading' 55611 30148 } ], @@ -55638,7 +30175,7 @@ module.exports = { 55638 30175 all: [], 55639 30176 any: [ { 55640 30177 options: {55641 -1 regionMatcher: 'dialog, [role=dialog], [role=alertdialog], svg, iframe'-1 30178 regionMatcher: 'dialog, [role=dialog], [role=alertdialog], svg' 55642 30179 }, 55643 30180 id: 'region' 55644 30181 } ], @@ -55648,6 +30185,7 @@ module.exports = { 55648 30185 selector: '[role=\'img\']:not(img, area, input, object)', 55649 30186 matches: 'html-namespace-matches', 55650 30187 tags: [ 'cat.text-alternatives', 'wcag2a', 'wcag111', 'section508', 'section508.22.a', 'ACT' ], -1 30188 actIds: [ '23a2a8' ], 55651 30189 all: [], 55652 30190 any: [ 'aria-label', 'aria-labelledby', { 55653 30191 options: { @@ -55672,6 +30210,7 @@ module.exports = { 55672 30210 id: 'scrollable-region-focusable', 55673 30211 matches: 'scrollable-region-focusable-matches', 55674 30212 tags: [ 'cat.keyboard', 'wcag2a', 'wcag211' ], -1 30213 actIds: [ '0ssw9k' ], 55675 30214 all: [], 55676 30215 any: [ 'focusable-content', 'focusable-element' ], 55677 30216 none: [] @@ -55679,6 +30218,7 @@ module.exports = { 55679 30218 id: 'select-name', 55680 30219 selector: 'select', 55681 30220 tags: [ 'cat.forms', 'wcag2a', 'wcag412', 'wcag131', 'section508', 'section508.22.n', 'ACT' ], -1 30221 actIds: [ 'e086e5' ], 55682 30222 all: [], 55683 30223 any: [ 'implicit-label', 'explicit-label', 'aria-label', 'aria-labelledby', { 55684 30224 options: { @@ -55707,6 +30247,7 @@ module.exports = { 55707 30247 selector: '[role="img"], [role="graphics-symbol"], svg[role="graphics-document"]', 55708 30248 matches: 'svg-namespace-matches', 55709 30249 tags: [ 'cat.text-alternatives', 'wcag2a', 'wcag111', 'section508', 'section508.22.a', 'ACT' ], -1 30250 actIds: [ '7d6734' ], 55710 30251 all: [], 55711 30252 any: [ 'svg-non-empty-title', 'aria-label', 'aria-labelledby', { 55712 30253 options: { @@ -55749,6 +30290,7 @@ module.exports = { 55749 30290 id: 'td-headers-attr', 55750 30291 selector: 'table', 55751 30292 tags: [ 'cat.tables', 'wcag2a', 'wcag131', 'section508', 'section508.22.g' ], -1 30293 actIds: [ 'a25f45' ], 55752 30294 all: [ 'td-headers-attr' ], 55753 30295 any: [], 55754 30296 none: [] @@ -55757,6 +30299,7 @@ module.exports = { 55757 30299 selector: 'table', 55758 30300 matches: 'data-table-matches', 55759 30301 tags: [ 'cat.tables', 'wcag2a', 'wcag131', 'section508', 'section508.22.g' ], -1 30302 actIds: [ 'd0f69e' ], 55760 30303 all: [ 'th-has-data-cells' ], 55761 30304 any: [], 55762 30305 none: [] @@ -55778,6 +30321,7 @@ module.exports = { 55778 30321 selector: 'video', 55779 30322 excludeHidden: false, 55780 30323 tags: [ 'cat.text-alternatives', 'wcag2a', 'wcag122', 'section508', 'section508.22.a' ], -1 30324 actIds: [ 'eac66b' ], 55781 30325 all: [], 55782 30326 any: [], 55783 30327 none: [ 'caption' ] @@ -55787,7 +30331,10 @@ module.exports = { 55787 30331 evaluate: 'abstractrole-evaluate' 55788 30332 }, { 55789 30333 id: 'aria-allowed-attr',55790 -1 evaluate: 'aria-allowed-attr-evaluate'-1 30334 evaluate: 'aria-allowed-attr-evaluate', -1 30335 options: { -1 30336 validTreeRowAttrs: [ 'aria-posinset', 'aria-setsize', 'aria-expanded', 'aria-level' ] -1 30337 } 55791 30338 }, { 55792 30339 id: 'aria-allowed-role', 55793 30340 evaluate: 'aria-allowed-role-evaluate', @@ -55802,6 +30349,9 @@ module.exports = { 55802 30349 id: 'aria-hidden-body', 55803 30350 evaluate: 'aria-hidden-body-evaluate' 55804 30351 }, { -1 30352 id: 'aria-level', -1 30353 evaluate: 'aria-level-evaluate' -1 30354 }, { 55805 30355 id: 'aria-prohibited-attr', 55806 30356 evaluate: 'aria-prohibited-attr-evaluate', 55807 30357 options: { @@ -55840,6 +30390,9 @@ module.exports = { 55840 30390 evaluate: 'aria-valid-attr-evaluate', 55841 30391 options: [] 55842 30392 }, { -1 30393 id: 'deprecatedrole', -1 30394 evaluate: 'deprecatedrole-evaluate' -1 30395 }, { 55843 30396 id: 'fallbackrole', 55844 30397 evaluate: 'fallbackrole-evaluate' 55845 30398 }, { @@ -55868,11 +30421,33 @@ module.exports = { 55868 30421 roles: [ 'tooltip' ] 55869 30422 } 55870 30423 }, { -1 30424 id: 'color-contrast-enhanced', -1 30425 evaluate: 'color-contrast-evaluate', -1 30426 options: { -1 30427 ignoreUnicode: true, -1 30428 ignoreLength: false, -1 30429 ignorePseudo: false, -1 30430 boldValue: 700, -1 30431 boldTextPt: 14, -1 30432 largeTextPt: 18, -1 30433 contrastRatio: { -1 30434 normal: { -1 30435 expected: 7 -1 30436 }, -1 30437 large: { -1 30438 expected: 4.5 -1 30439 } -1 30440 }, -1 30441 pseudoSizeThreshold: .25, -1 30442 shadowOutlineEmMax: .1 -1 30443 } -1 30444 }, { 55871 30445 id: 'color-contrast', 55872 30446 evaluate: 'color-contrast-evaluate', 55873 30447 options: { 55874 30448 ignoreUnicode: true, 55875 30449 ignoreLength: false, -1 30450 ignorePseudo: false, 55876 30451 boldValue: 700, 55877 30452 boldTextPt: 14, 55878 30453 largeTextPt: 18, @@ -55884,17 +30459,22 @@ module.exports = { 55884 30459 expected: 3 55885 30460 } 55886 30461 },55887 -1 shadowOutlineEmMax: .1-1 30462 pseudoSizeThreshold: .25, -1 30463 shadowOutlineEmMax: .2 55888 30464 } 55889 30465 }, { 55890 30466 id: 'link-in-text-block', 55891 30467 evaluate: 'link-in-text-block-evaluate' 55892 30468 }, { 55893 30469 id: 'autocomplete-appropriate',55894 -1 evaluate: 'autocomplete-appropriate-evaluate'-1 30470 evaluate: 'autocomplete-appropriate-evaluate', -1 30471 deprecated: true 55895 30472 }, { 55896 30473 id: 'autocomplete-valid',55897 -1 evaluate: 'autocomplete-valid-evaluate'-1 30474 evaluate: 'autocomplete-valid-evaluate', -1 30475 options: { -1 30476 stateTerms: [ 'none', 'false', 'true', 'disabled', 'enabled', 'undefined', 'null' ] -1 30477 } 55898 30478 }, { 55899 30479 id: 'accesskeys', 55900 30480 evaluate: 'accesskeys-evaluate', @@ -55919,7 +30499,7 @@ module.exports = { 55919 30499 evaluate: 'focusable-not-tabbable-evaluate' 55920 30500 }, { 55921 30501 id: 'frame-focusable-content',55922 -1 evaluate: 'no-focusable-content-evaluate'-1 30502 evaluate: 'frame-focusable-content-evaluate' 55923 30503 }, { 55924 30504 id: 'landmark-is-top-level', 55925 30505 evaluate: 'landmark-is-top-level-evaluate' @@ -56112,13 +30692,16 @@ module.exports = { 56112 30692 size: 1.15 56113 30693 }, { 56114 30694 size: 1.456115 -1 } ]-1 30695 } ], -1 30696 passLength: 1, -1 30697 failLength: .5 56116 30698 } 56117 30699 }, { 56118 30700 id: 'region', 56119 30701 evaluate: 'region-evaluate', -1 30702 after: 'region-after', 56120 30703 options: {56121 -1 regionMatcher: 'dialog, [role=dialog], [role=alertdialog], svg, iframe'-1 30704 regionMatcher: 'dialog, [role=dialog], [role=alertdialog], svg' 56122 30705 } 56123 30706 }, { 56124 30707 id: 'skip-link', @@ -56255,7 +30838,7 @@ module.exports = { 56255 30838 }); 56256 30839 })(typeof window === 'object' ? window : this); 56257 30840 }).call(this)}).call(this,require('_process'),require("timers").setImmediate)56258 -1 },{"_process":149,"crypto":71,"timers":186}],201:[function(require,module,exports){-1 30841 },{"_process":1,"timers":2}],16:[function(require,module,exports){ 56259 30842 "use strict"; 56260 30843 56261 30844 exports.__esModule = true; @@ -56265,17 +30848,16 @@ var _accessibleNameAndDescription = require("./accessible-name-and-description") 56265 30848 56266 30849 var _util = require("./util"); 56267 3085056268 -1 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }-1 30851 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } 56269 3085256270 -1 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }-1 30853 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } 56271 30854 56272 30855 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 56273 30856 56274 30857 /**56275 -1 * implements https://w3c.github.io/accname/#mapping_additional_nd_description56276 30858 * @param root56277 -1 * @param [options]56278 -1 * @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`-1 30859 * @param options -1 30860 * @returns 56279 30861 */ 56280 30862 function computeAccessibleDescription(root) { 56281 30863 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; @@ -56297,7 +30879,7 @@ function computeAccessibleDescription(root) { 56297 30879 return description; 56298 30880 } 56299 3088156300 -1 },{"./accessible-name-and-description":202,"./util":208}],202:[function(require,module,exports){-1 30882 },{"./accessible-name-and-description":17,"./util":24}],17:[function(require,module,exports){ 56301 30883 "use strict"; 56302 30884 56303 30885 exports.__esModule = true; @@ -56559,8 +31141,8 @@ function getSlotContents(slot) { 56559 31141 /** 56560 31142 * implements https://w3c.github.io/accname/#mapping_additional_nd_te 56561 31143 * @param root56562 -1 * @param [options]56563 -1 * @param [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`-1 31144 * @param options -1 31145 * @returns 56564 31146 */ 56565 31147 56566 31148 @@ -56573,7 +31155,9 @@ function computeTextAlternative(root) { 56573 31155 _options$computedStyl = options.computedStyleSupportsPseudoElements, 56574 31156 computedStyleSupportsPseudoElements = _options$computedStyl === void 0 ? options.getComputedStyle !== undefined : _options$computedStyl, 56575 31157 _options$getComputedS = options.getComputedStyle,56576 -1 getComputedStyle = _options$getComputedS === void 0 ? window.getComputedStyle.bind(window) : _options$getComputedS; // 2F.i-1 31158 getComputedStyle = _options$getComputedS === void 0 ? window.getComputedStyle.bind(window) : _options$getComputedS, -1 31159 _options$hidden = options.hidden, -1 31160 hidden = _options$hidden === void 0 ? false : _options$hidden; // 2F.i 56577 31161 56578 31162 function computeMiscTextAlternative(node, context) { 56579 31163 var accumulatedText = ""; @@ -56607,7 +31191,7 @@ function computeTextAlternative(root) { 56607 31191 accumulatedText = "".concat(accumulatedText, " ").concat(afterContent); 56608 31192 } 56609 3119356610 -1 return accumulatedText;-1 31194 return accumulatedText.trim(); 56611 31195 } 56612 31196 56613 31197 function computeElementTextAlternative(node) { @@ -56751,23 +31335,30 @@ function computeTextAlternative(root) { 56751 31335 return "Submit Query"; 56752 31336 } 56753 31337 -1 31338 if ((0, _util.hasAnyConcreteRoles)(node, ["button"])) { -1 31339 // https://www.w3.org/TR/html-aam-1.0/#button-element -1 31340 var nameFromSubTree = computeMiscTextAlternative(node, { -1 31341 isEmbeddedInLabel: false, -1 31342 isReferenced: false -1 31343 }); -1 31344 -1 31345 if (nameFromSubTree !== "") { -1 31346 return nameFromSubTree; -1 31347 } -1 31348 -1 31349 return useAttribute(node, "title"); -1 31350 } -1 31351 56754 31352 return useAttribute(node, "title"); 56755 31353 } 56756 31354 56757 31355 function computeTextAlternative(current, context) { 56758 31356 if (consultedNodes.has(current)) { 56759 31357 return "";56760 -1 } // special casing, cheating to make tests pass56761 -1 // https://github.com/w3c/accname/issues/6756762 -156763 -156764 -1 if ((0, _util.hasAnyConcreteRoles)(current, ["menu"])) {56765 -1 consultedNodes.add(current);56766 -1 return "";56767 31358 } // 2A 56768 31359 56769 3136056770 -1 if (isHidden(current, getComputedStyle) && !context.isReferenced) {-1 31361 if (!hidden && isHidden(current, getComputedStyle) && !context.isReferenced) { 56771 31362 consultedNodes.add(current); 56772 31363 return ""; 56773 31364 } // 2B @@ -56810,6 +31401,13 @@ function computeTextAlternative(root) { 56810 31401 return elementTextAlternative; 56811 31402 } 56812 31403 } -1 31404 } // special casing, cheating to make tests pass -1 31405 // https://github.com/w3c/accname/issues/67 -1 31406 -1 31407 -1 31408 if ((0, _util.hasAnyConcreteRoles)(current, ["menu"])) { -1 31409 consultedNodes.add(current); -1 31410 return ""; 56813 31411 } // 2E 56814 31412 56815 31413 @@ -56897,7 +31495,7 @@ function computeTextAlternative(root) { 56897 31495 })); 56898 31496 } 56899 3149756900 -1 },{"./polyfills/SetLike":206,"./polyfills/array.from":207,"./util":208}],203:[function(require,module,exports){-1 31498 },{"./polyfills/SetLike":22,"./polyfills/array.from":23,"./util":24}],18:[function(require,module,exports){ 56901 31499 "use strict"; 56902 31500 56903 31501 exports.__esModule = true; @@ -56916,8 +31514,8 @@ function prohibitsNaming(node) { 56916 31514 /** 56917 31515 * implements https://w3c.github.io/accname/#mapping_additional_nd_name 56918 31516 * @param root56919 -1 * @param [options]56920 -1 * @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`-1 31517 * @param options -1 31518 * @returns 56921 31519 */ 56922 31520 56923 31521 @@ -56931,19 +31529,31 @@ function computeAccessibleName(root) { 56931 31529 return (0, _accessibleNameAndDescription.computeTextAlternative)(root, options); 56932 31530 } 56933 3153156934 -1 },{"./accessible-name-and-description":202,"./util":208}],204:[function(require,module,exports){-1 31532 },{"./accessible-name-and-description":17,"./util":24}],19:[function(require,module,exports){ 56935 31533 "use strict"; 56936 31534 56937 31535 exports.__esModule = true; 56938 31536 exports.default = getRole;56939 -156940 -1 var _util = require("./util");-1 31537 exports.getLocalName = getLocalName; 56941 31538 56942 31539 // https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html -1 31540 -1 31541 /** -1 31542 * Safe Element.localName for all supported environments -1 31543 * @param element -1 31544 */ -1 31545 function getLocalName(element) { -1 31546 var _element$localName; -1 31547 -1 31548 return (// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName -1 31549 (_element$localName = element.localName) !== null && _element$localName !== void 0 ? _element$localName : // eslint-disable-next-line no-restricted-properties -- required for the fallback -1 31550 element.tagName.toLowerCase() -1 31551 ); -1 31552 } -1 31553 56943 31554 var localNameToRoleMappings = { 56944 31555 article: "article", 56945 31556 aside: "complementary",56946 -1 body: "document",56947 31557 button: "button", 56948 31558 datalist: "listbox", 56949 31559 dd: "definition", @@ -56963,6 +31573,7 @@ var localNameToRoleMappings = { 56963 31573 h6: "heading", 56964 31574 header: "banner", 56965 31575 hr: "separator", -1 31576 html: "document", 56966 31577 legend: "legend", 56967 31578 li: "listitem", 56968 31579 math: "math", @@ -57042,13 +31653,13 @@ function getRole(element) { 57042 31653 } 57043 31654 57044 31655 function getImplicitRole(element) {57045 -1 var mappedByTag = localNameToRoleMappings[(0, _util.getLocalName)(element)];-1 31656 var mappedByTag = localNameToRoleMappings[getLocalName(element)]; 57046 31657 57047 31658 if (mappedByTag !== undefined) { 57048 31659 return mappedByTag; 57049 31660 } 57050 3166157051 -1 switch ((0, _util.getLocalName)(element)) {-1 31662 switch (getLocalName(element)) { 57052 31663 case "a": 57053 31664 case "area": 57054 31665 case "link": @@ -57101,6 +31712,9 @@ function getImplicitRole(element) { 57101 31712 57102 31713 return "searchbox"; 57103 31714 -1 31715 case "number": -1 31716 return "spinbutton"; -1 31717 57104 31718 default: 57105 31719 return null; 57106 31720 } @@ -57132,10 +31746,15 @@ function getExplicitRole(element) { 57132 31746 return null; 57133 31747 } 57134 3174857135 -1 },{"./util":208}],205:[function(require,module,exports){-1 31749 },{}],20:[function(require,module,exports){ 57136 31750 "use strict"; 57137 31751 57138 31752 exports.__esModule = true; -1 31753 var _exportNames = { -1 31754 computeAccessibleDescription: true, -1 31755 computeAccessibleName: true, -1 31756 getRole: true -1 31757 }; 57139 31758 exports.getRole = exports.computeAccessibleName = exports.computeAccessibleDescription = void 0; 57140 31759 57141 31760 var _accessibleDescription = require("./accessible-description"); @@ -57150,9 +31769,102 @@ var _getRole = _interopRequireDefault(require("./getRole")); 57150 31769 57151 31770 exports.getRole = _getRole.default; 57152 31771 -1 31772 var _isInaccessible = require("./is-inaccessible"); -1 31773 -1 31774 Object.keys(_isInaccessible).forEach(function (key) { -1 31775 if (key === "default" || key === "__esModule") return; -1 31776 if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; -1 31777 if (key in exports && exports[key] === _isInaccessible[key]) return; -1 31778 exports[key] = _isInaccessible[key]; -1 31779 }); -1 31780 57153 31781 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 57154 3178257155 -1 },{"./accessible-description":201,"./accessible-name":203,"./getRole":204}],206:[function(require,module,exports){-1 31783 },{"./accessible-description":16,"./accessible-name":18,"./getRole":19,"./is-inaccessible":21}],21:[function(require,module,exports){ -1 31784 "use strict"; -1 31785 -1 31786 exports.__esModule = true; -1 31787 exports.isInaccessible = isInaccessible; -1 31788 exports.isSubtreeInaccessible = isSubtreeInaccessible; -1 31789 -1 31790 /** -1 31791 * Partial implementation https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion -1 31792 * which should only be used for elements with a non-presentational role i.e. -1 31793 * `role="none"` and `role="presentation"` will not be excluded. -1 31794 * -1 31795 * Implements aria-hidden semantics (i.e. parent overrides child) -1 31796 * Ignores "Child Presentational: True" characteristics -1 31797 * -1 31798 * @param element -1 31799 * @param options -1 31800 * @returns {boolean} true if excluded, otherwise false -1 31801 */ -1 31802 function isInaccessible(element) { -1 31803 var _element$ownerDocumen; -1 31804 -1 31805 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; -1 31806 var _options$getComputedS = options.getComputedStyle, -1 31807 getComputedStyle = _options$getComputedS === void 0 ? (_element$ownerDocumen = element.ownerDocument.defaultView) === null || _element$ownerDocumen === void 0 ? void 0 : _element$ownerDocumen.getComputedStyle : _options$getComputedS, -1 31808 _options$isSubtreeIna = options.isSubtreeInaccessible, -1 31809 isSubtreeInaccessibleImpl = _options$isSubtreeIna === void 0 ? isSubtreeInaccessible : _options$isSubtreeIna; -1 31810 -1 31811 if (typeof getComputedStyle !== "function") { -1 31812 throw new TypeError("Owner document of the element needs to have an associated window."); -1 31813 } // since visibility is inherited we can exit early -1 31814 -1 31815 -1 31816 if (getComputedStyle(element).visibility === "hidden") { -1 31817 return true; -1 31818 } -1 31819 -1 31820 var currentElement = element; -1 31821 -1 31822 while (currentElement) { -1 31823 if (isSubtreeInaccessibleImpl(currentElement, { -1 31824 getComputedStyle: getComputedStyle -1 31825 })) { -1 31826 return true; -1 31827 } -1 31828 -1 31829 currentElement = currentElement.parentElement; -1 31830 } -1 31831 -1 31832 return false; -1 31833 } -1 31834 -1 31835 /** -1 31836 * -1 31837 * @param element -1 31838 * @param options -1 31839 * @returns {boolean} - `true` if every child of the element is inaccessible -1 31840 */ -1 31841 function isSubtreeInaccessible(element) { -1 31842 var _element$ownerDocumen2; -1 31843 -1 31844 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; -1 31845 var _options$getComputedS2 = options.getComputedStyle, -1 31846 getComputedStyle = _options$getComputedS2 === void 0 ? (_element$ownerDocumen2 = element.ownerDocument.defaultView) === null || _element$ownerDocumen2 === void 0 ? void 0 : _element$ownerDocumen2.getComputedStyle : _options$getComputedS2; -1 31847 -1 31848 if (typeof getComputedStyle !== "function") { -1 31849 throw new TypeError("Owner document of the element needs to have an associated window."); -1 31850 } -1 31851 -1 31852 if (element.hidden === true) { -1 31853 return true; -1 31854 } -1 31855 -1 31856 if (element.getAttribute("aria-hidden") === "true") { -1 31857 return true; -1 31858 } -1 31859 -1 31860 if (getComputedStyle(element).display === "none") { -1 31861 return true; -1 31862 } -1 31863 -1 31864 return false; -1 31865 } -1 31866 -1 31867 },{}],22:[function(require,module,exports){ 57156 31868 "use strict"; 57157 31869 57158 31870 exports.__esModule = true; @@ -57162,7 +31874,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons 57162 31874 57163 31875 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 57164 3187657165 -1 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }-1 31877 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 57166 31878 57167 31879 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 57168 31880 @@ -57229,7 +31941,7 @@ var _default = typeof Set === "undefined" ? Set : SetLike; 57229 31941 57230 31942 exports.default = _default; 57231 3194357232 -1 },{}],207:[function(require,module,exports){-1 31944 },{}],23:[function(require,module,exports){ 57233 31945 "use strict"; 57234 31946 57235 31947 exports.__esModule = true; @@ -57329,71 +32041,63 @@ function arrayFrom(arrayLike, mapFn) { 57329 32041 return A; 57330 32042 } 57331 3204357332 -1 },{}],208:[function(require,module,exports){-1 32044 },{}],24:[function(require,module,exports){ 57333 32045 "use strict"; 57334 32046 -1 32047 function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } -1 32048 57335 32049 exports.__esModule = true;57336 -1 exports.getLocalName = getLocalName;-1 32050 exports.hasAnyConcreteRoles = hasAnyConcreteRoles; 57337 32051 exports.isElement = isElement;57338 -1 exports.isHTMLTableCaptionElement = isHTMLTableCaptionElement;-1 32052 exports.isHTMLFieldSetElement = isHTMLFieldSetElement; 57339 32053 exports.isHTMLInputElement = isHTMLInputElement; -1 32054 exports.isHTMLLegendElement = isHTMLLegendElement; 57340 32055 exports.isHTMLOptGroupElement = isHTMLOptGroupElement; 57341 32056 exports.isHTMLSelectElement = isHTMLSelectElement; -1 32057 exports.isHTMLSlotElement = isHTMLSlotElement; -1 32058 exports.isHTMLTableCaptionElement = isHTMLTableCaptionElement; 57342 32059 exports.isHTMLTableElement = isHTMLTableElement; 57343 32060 exports.isHTMLTextAreaElement = isHTMLTextAreaElement;57344 -1 exports.safeWindow = safeWindow;57345 -1 exports.isHTMLFieldSetElement = isHTMLFieldSetElement;57346 -1 exports.isHTMLLegendElement = isHTMLLegendElement;57347 -1 exports.isHTMLSlotElement = isHTMLSlotElement;57348 32061 exports.isSVGElement = isSVGElement; 57349 32062 exports.isSVGSVGElement = isSVGSVGElement; 57350 32063 exports.isSVGTitleElement = isSVGTitleElement; 57351 32064 exports.queryIdRefs = queryIdRefs;57352 -1 exports.hasAnyConcreteRoles = hasAnyConcreteRoles;-1 32065 exports.safeWindow = safeWindow; 57353 3206657354 -1 var _getRole = _interopRequireDefault(require("./getRole"));-1 32067 var _getRole = _interopRequireWildcard(require("./getRole")); 57355 3206857356 -1 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }-1 32069 exports.getLocalName = _getRole.getLocalName; 57357 3207057358 -1 /**57359 -1 * Safe Element.localName for all supported environments57360 -1 * @param element57361 -1 */57362 -1 function getLocalName(element) {57363 -1 var _element$localName;-1 32071 function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } 57364 3207257365 -1 return (// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName57366 -1 (_element$localName = element.localName) !== null && _element$localName !== void 0 ? _element$localName : // eslint-disable-next-line no-restricted-properties -- required for the fallback57367 -1 element.tagName.toLowerCase()57368 -1 );57369 -1 }-1 32073 function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 57370 32074 57371 32075 function isElement(node) { 57372 32076 return node !== null && node.nodeType === node.ELEMENT_NODE; 57373 32077 } 57374 32078 57375 32079 function isHTMLTableCaptionElement(node) {57376 -1 return isElement(node) && getLocalName(node) === "caption";-1 32080 return isElement(node) && (0, _getRole.getLocalName)(node) === "caption"; 57377 32081 } 57378 32082 57379 32083 function isHTMLInputElement(node) {57380 -1 return isElement(node) && getLocalName(node) === "input";-1 32084 return isElement(node) && (0, _getRole.getLocalName)(node) === "input"; 57381 32085 } 57382 32086 57383 32087 function isHTMLOptGroupElement(node) {57384 -1 return isElement(node) && getLocalName(node) === "optgroup";-1 32088 return isElement(node) && (0, _getRole.getLocalName)(node) === "optgroup"; 57385 32089 } 57386 32090 57387 32091 function isHTMLSelectElement(node) {57388 -1 return isElement(node) && getLocalName(node) === "select";-1 32092 return isElement(node) && (0, _getRole.getLocalName)(node) === "select"; 57389 32093 } 57390 32094 57391 32095 function isHTMLTableElement(node) {57392 -1 return isElement(node) && getLocalName(node) === "table";-1 32096 return isElement(node) && (0, _getRole.getLocalName)(node) === "table"; 57393 32097 } 57394 32098 57395 32099 function isHTMLTextAreaElement(node) {57396 -1 return isElement(node) && getLocalName(node) === "textarea";-1 32100 return isElement(node) && (0, _getRole.getLocalName)(node) === "textarea"; 57397 32101 } 57398 32102 57399 32103 function safeWindow(node) { @@ -57408,15 +32112,15 @@ function safeWindow(node) { 57408 32112 } 57409 32113 57410 32114 function isHTMLFieldSetElement(node) {57411 -1 return isElement(node) && getLocalName(node) === "fieldset";-1 32115 return isElement(node) && (0, _getRole.getLocalName)(node) === "fieldset"; 57412 32116 } 57413 32117 57414 32118 function isHTMLLegendElement(node) {57415 -1 return isElement(node) && getLocalName(node) === "legend";-1 32119 return isElement(node) && (0, _getRole.getLocalName)(node) === "legend"; 57416 32120 } 57417 32121 57418 32122 function isHTMLSlotElement(node) {57419 -1 return isElement(node) && getLocalName(node) === "slot";-1 32123 return isElement(node) && (0, _getRole.getLocalName)(node) === "slot"; 57420 32124 } 57421 32125 57422 32126 function isSVGElement(node) { @@ -57424,11 +32128,11 @@ function isSVGElement(node) { 57424 32128 } 57425 32129 57426 32130 function isSVGSVGElement(node) {57427 -1 return isElement(node) && getLocalName(node) === "svg";-1 32131 return isElement(node) && (0, _getRole.getLocalName)(node) === "svg"; 57428 32132 } 57429 32133 57430 32134 function isSVGTitleElement(node) {57431 -1 return isSVGElement(node) && getLocalName(node) === "title";-1 32135 return isSVGElement(node) && (0, _getRole.getLocalName)(node) === "title"; 57432 32136 } 57433 32137 /** 57434 32138 * @@ -57441,9 +32145,11 @@ function isSVGTitleElement(node) { 57441 32145 function queryIdRefs(node, attributeName) { 57442 32146 if (isElement(node) && node.hasAttribute(attributeName)) { 57443 32147 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute check57444 -1 var ids = node.getAttribute(attributeName).split(" ");-1 32148 var ids = node.getAttribute(attributeName).split(" "); // Browsers that don't support shadow DOM won't have getRootNode -1 32149 -1 32150 var root = node.getRootNode ? node.getRootNode() : node.ownerDocument; 57445 32151 return ids.map(function (id) {57446 -1 return node.ownerDocument.getElementById(id);-1 32152 return root.getElementById(id); 57447 32153 }).filter(function (element) { 57448 32154 return element !== null; 57449 32155 } // TODO: why does this not narrow? @@ -57461,13 +32167,13 @@ function hasAnyConcreteRoles(node, roles) { 57461 32167 return false; 57462 32168 } 57463 3216957464 -1 },{"./getRole":204}],209:[function(require,module,exports){57465 -1 /*!-1 32170 },{"./getRole":19}],25:[function(require,module,exports){ -1 32171 /*@license 57466 32172 CalcNames: The AccName Computation Prototype, compute the Name and Description property values for a DOM node 57467 32173 Returns an object with 'name' and 'desc' properties. 57468 32174 Functionality mirrors the steps within the W3C Accessible Name and Description computation algorithm.57469 -1 http://www.w3.org/TR/accname-aam-1.1/57470 -1 Authored by Bryan Garaventa, plus refactoring contrabutions by Tobias Bengfort-1 32175 https://w3c.github.io/accname/ -1 32176 Author: Bryan Garaventa 57471 32177 https://github.com/whatsock/w3c-alternative-text-computation 57472 32178 Distributed under the terms of the Open Source Initiative OSI - MIT License 57473 32179 */ @@ -57478,7 +32184,7 @@ Distributed under the terms of the Open Source Initiative OSI - MIT License 57478 32184 window[nameSpace] = {}; 57479 32185 nameSpace = window[nameSpace]; 57480 32186 }57481 -1 nameSpace.getAccNameVersion = "2.55";-1 32187 nameSpace.getAccNameVersion = "2.59"; 57482 32188 // AccName Computation Prototype 57483 32189 nameSpace.getAccName = nameSpace.calcNames = function( 57484 32190 node, @@ -57498,7 +32204,11 @@ Distributed under the terms of the Open Source Initiative OSI - MIT License 57498 32204 var rootNode = node; 57499 32205 var rootRole = trim(node.getAttribute("role") || ""); 57500 32206 // Track nodes to prevent duplicate node reference parsing.57501 -1 var nodes = [];-1 32207 // Separating Name and Description to prevent duplicate node references from suppressing one or the other from being fully computed. -1 32208 var nodes = { -1 32209 name: [], -1 32210 desc: [] -1 32211 }; 57502 32212 // Track aria-owns references to prevent duplicate parsing. 57503 32213 var owns = []; 57504 32214 @@ -57611,7 +32321,12 @@ Plus roles extended for the Role Parity project. 57611 32321 after: "" 57612 32322 }; 57613 3232357614 -1 if (!skipTo.tag && !skipTo.role && nodes.indexOf(refNode) === -1) {-1 32324 if ( -1 32325 !skipTo.tag && -1 32326 !skipTo.role && -1 32327 nodes[!ownedBy.computingDesc ? "name" : "desc"].indexOf(refNode) === -1 32328 -1 -1 32329 ) { 57615 32330 // Store the before and after pseudo element 'content' values for the top level DOM node 57616 32331 // Note: If the pseudo element includes block level styling, a space will be added, otherwise inline is asumed and no spacing is added. 57617 32332 cssOP = getCSSText(refNode, null); @@ -57737,8 +32452,13 @@ Plus roles extended for the Role Parity project. 57737 32452 return result; 57738 32453 } 57739 3245457740 -1 if (!skipTo.tag && !skipTo.role && nodes.indexOf(node) === -1) {57741 -1 nodes.push(node);-1 32455 if ( -1 32456 !skipTo.tag && -1 32457 !skipTo.role && -1 32458 nodes[!ownedBy.computingDesc ? "name" : "desc"].indexOf(node) === -1 32459 -1 -1 32460 ) { -1 32461 nodes[!ownedBy.computingDesc ? "name" : "desc"].push(node); 57742 32462 } else { 57743 32463 // Abort if this node has already been processed. 57744 32464 return result; @@ -57755,8 +32475,14 @@ Plus roles extended for the Role Parity project. 57755 32475 }; 57756 32476 57757 32477 var parent = refNode === node ? node : node.parentNode;57758 -1 if (!skipTo.tag && !skipTo.role && nodes.indexOf(parent) === -1) {57759 -1 nodes.push(parent);-1 32478 if ( -1 32479 !skipTo.tag && -1 32480 !skipTo.role && -1 32481 nodes[!ownedBy.computingDesc ? "name" : "desc"].indexOf( -1 32482 parent -1 32483 ) === -1 -1 32484 ) { -1 32485 nodes[!ownedBy.computingDesc ? "name" : "desc"].push(parent); 57760 32486 // Store the before and after pseudo element 'content' values for the current node container element 57761 32487 // Note: If the pseudo element includes block level styling, a space will be added, otherwise inline is asumed and no spacing is added. 57762 32488 cssO = getCSSText(parent, refNode); @@ -57805,6 +32531,17 @@ Plus roles extended for the Role Parity project. 57805 32531 (!skipTo.tag && !skipTo.role && node.getAttribute("title")) || 57806 32532 ""; 57807 32533 -1 32534 // Added to prevent name on generic elements. -1 32535 // https://www.w3.org/TR/wai-aria-1.2/#generic -1 32536 var isGeneric = -1 32537 node === rootNode && -1 32538 !nRole && -1 32539 genericElements.indexOf(nTag) !== -1; -1 32540 if (isGeneric) { -1 32541 // Abort since an implicitly generic rootNode cannot have a name -1 32542 return result; -1 32543 } -1 32544 57808 32545 var isNativeFormField = nativeFormFields.indexOf(nTag) !== -1; 57809 32546 var isNativeButton = ["input"].indexOf(nTag) !== -1; 57810 32547 var isRangeWidgetRole = rangeWidgetRoles.indexOf(nRole) !== -1; @@ -57836,6 +32573,32 @@ Plus roles extended for the Role Parity project. 57836 32573 ownedBy[node.id].target === node)) 57837 32574 ); 57838 32575 -1 32576 // Check for non-empty value of aria-labelledby on current node, follow each ID ref, then stop and process no deeper. -1 32577 if (!stop && !skipTo.tag && !skipTo.role && aLabelledby) { -1 32578 ids = aLabelledby.split(/\s+/); -1 32579 parts = []; -1 32580 for (i = 0; i < ids.length; i++) { -1 32581 element = docO.getElementById(ids[i]); -1 32582 // Also prevent the current form field from having its value included in the naming computation if nested as a child of label -1 32583 parts.push( -1 32584 walk(element, true, skip, [node], element === refNode, { -1 32585 ref: ownedBy, -1 32586 top: element -1 32587 }).name -1 32588 ); -1 32589 } -1 32590 // Check for blank value, since whitespace chars alone are not valid as a name -1 32591 name = trim(parts.join(" ")); -1 32592 -1 32593 if (trim(name)) { -1 32594 hasName = true; -1 32595 hLabel = true; -1 32596 hasLabel = true; -1 32597 // Abort further recursion if name is valid. -1 32598 result.skip = true; -1 32599 } -1 32600 } -1 32601 57839 32602 // Check for non-empty value of aria-describedby/description if current node equals reference node, follow each ID ref, then stop and process no deeper. 57840 32603 if ( 57841 32604 !stop && @@ -57854,7 +32617,8 @@ Plus roles extended for the Role Parity project. 57854 32617 parts.push( 57855 32618 walk(element, true, false, [node], false, { 57856 32619 ref: ownedBy,57857 -1 top: element-1 32620 top: element, -1 32621 computingDesc: true 57858 32622 }).name 57859 32623 ); 57860 32624 } @@ -57869,32 +32633,6 @@ Plus roles extended for the Role Parity project. 57869 32633 } 57870 32634 } 57871 3263557872 -1 // Check for non-empty value of aria-labelledby on current node, follow each ID ref, then stop and process no deeper.57873 -1 if (!stop && !skipTo.tag && !skipTo.role && aLabelledby) {57874 -1 ids = aLabelledby.split(/\s+/);57875 -1 parts = [];57876 -1 for (i = 0; i < ids.length; i++) {57877 -1 element = docO.getElementById(ids[i]);57878 -1 // Also prevent the current form field from having its value included in the naming computation if nested as a child of label57879 -1 parts.push(57880 -1 walk(element, true, skip, [node], element === refNode, {57881 -1 ref: ownedBy,57882 -1 top: element57883 -1 }).name57884 -1 );57885 -1 }57886 -1 // Check for blank value, since whitespace chars alone are not valid as a name57887 -1 name = trim(parts.join(" "));57888 -157889 -1 if (trim(name)) {57890 -1 hasName = true;57891 -1 hLabel = true;57892 -1 hasLabel = true;57893 -1 // Abort further recursion if name is valid.57894 -1 result.skip = true;57895 -1 }57896 -1 }57897 -157898 32636 // Otherwise, if current node has a non-empty aria-label then set as name and process no deeper within the branch. 57899 32637 if ( 57900 32638 !skipTo.tag && @@ -58147,32 +32885,6 @@ Plus roles extended for the Role Parity project. 58147 32885 skip = true; 58148 32886 } 58149 3288758150 -1 var isFigure =58151 -1 !skipTo.tag &&58152 -1 !skipTo.role &&58153 -1 !hasName &&58154 -1 (nRole === "figure" || (!nRole && nTag === "figure"));58155 -158156 -1 // Otherwise, if name is still empty and is a standard figure element with a non-empty associated figcaption element as the first or last child node, process caption with same naming computation algorithm.58157 -1 // Plus do the same for role="figure" with embedded role="caption", or a combination of these.58158 -1 if (isFigure) {58159 -1 fChild =58160 -1 firstChild(node, ["figcaption"], ["caption"]) ||58161 -1 lastChild(node, ["figcaption"], ["caption"]) ||58162 -1 false;58163 -1 if (fChild) {58164 -1 name = trim(58165 -1 walk(fChild, stop, false, [], false, {58166 -1 ref: ownedBy,58167 -1 top: fChild58168 -1 }).name58169 -1 );58170 -1 }58171 -1 if (trim(name)) {58172 -1 hasName = true;58173 -1 }58174 -1 }58175 -158176 32888 // Otherwise, if name is still empty and the root node and the current node are the same and node is an svg element, then parse the content of the title element to set the name and the desc element to set the description. 58177 32889 if (!skipTo.tag && !skipTo.role && nTag === "svg") { 58178 32890 var svgT = node.querySelector("title") || false; @@ -58603,6 +33315,7 @@ Plus roles extended for the Role Parity project. 58603 33315 tags: ["legend", "caption", "figcaption"] 58604 33316 }; 58605 33317 -1 33318 var genericElements = ["div", "span"]; 58606 33319 var nativeFormFields = ["button", "input", "select", "textarea"]; 58607 33320 var rangeWidgetRoles = ["scrollbar", "slider", "spinbutton"]; 58608 33321 var editWidgetRoles = ["searchbox", "textbox"]; @@ -59017,10 +33730,10 @@ Plus roles extended for the Role Parity project. 59017 33730 var accName = trim(accProps.name.replace(/\s+/g, " ")); 59018 33731 var accDesc = trim(accProps.title.replace(/\s+/g, " ")); 59019 3373259020 -1 if (accName === accDesc) {59021 -1 // If both Name and Description properties match, then clear the Description property value.59022 -1 accDesc = "";59023 -1 }-1 33733 // if (accName === accDesc) { -1 33734 // If both Name and Description properties match, then clear the Description property value. (Ideal but not in the spec so commented out.) -1 33735 // accDesc = ""; -1 33736 // } 59024 33737 59025 33738 props.hasUpperCase = 59026 33739 rootRole && rootRole !== rootRole.toLowerCase() ? true : false; @@ -59028,7 +33741,10 @@ Plus roles extended for the Role Parity project. 59028 33741 props.desc = accDesc; 59029 33742 59030 33743 // Clear track variables59031 -1 nodes = [];-1 33744 nodes = { -1 33745 name: [], -1 33746 desc: [] -1 33747 }; 59032 33748 owns = []; 59033 33749 } catch (e) { 59034 33750 props.error = e; @@ -59083,7 +33799,7 @@ Plus roles extended for the Role Parity project. 59083 33799 } 59084 33800 })(); 59085 3380159086 -1 },{}],210:[function(require,module,exports){-1 33802 },{}],26:[function(require,module,exports){ 59087 33803 (function (global){(function (){ 59088 33804 global.goog = { 59089 33805 provide: function() {}, @@ -59108,7 +33824,7 @@ require('accessibility-developer-tools/src/js/Properties'); 59108 33824 module.exports = global.axs; 59109 33825 59110 33826 }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})59111 -1 },{"accessibility-developer-tools/src/js/AccessibilityUtils":188,"accessibility-developer-tools/src/js/BrowserUtils":189,"accessibility-developer-tools/src/js/Color":190,"accessibility-developer-tools/src/js/Constants":191,"accessibility-developer-tools/src/js/DOMUtils":192,"accessibility-developer-tools/src/js/Properties":193}],211:[function(require,module,exports){-1 33827 },{"accessibility-developer-tools/src/js/AccessibilityUtils":3,"accessibility-developer-tools/src/js/BrowserUtils":4,"accessibility-developer-tools/src/js/Color":5,"accessibility-developer-tools/src/js/Constants":6,"accessibility-developer-tools/src/js/DOMUtils":7,"accessibility-developer-tools/src/js/Properties":8}],27:[function(require,module,exports){ 59112 33828 var ariaApi = require('aria-api'); 59113 33829 var accdc = require('w3c-alternative-text-computation'); 59114 33830 var axe = require('axe-core'); @@ -59128,7 +33844,7 @@ var ex = function(fn, args, _this) { 59128 33844 }; 59129 33845 59130 33846 var implementations = [{59131 -1 name: 'aria-api (0.4.1)',-1 33847 name: 'aria-api (0.4.2)', 59132 33848 url: 'https://github.com/xi/aria-api', 59133 33849 fn: function(el) { 59134 33850 return { @@ -59138,11 +33854,11 @@ var implementations = [{ 59138 33854 }; 59139 33855 }, 59140 33856 }, {59141 -1 name: 'accdc (2.55)',-1 33857 name: 'accdc (2.59)', 59142 33858 url: 'https://github.com/accdc/w3c-alternative-text-computation', 59143 33859 fn: accdc.calcNames, 59144 33860 }, {59145 -1 name: 'dom-accessibility-api (0.5.6)',-1 33861 name: 'dom-accessibility-api (0.5.14)', 59146 33862 url: 'https://github.com/eps1lon/dom-accessibility-api/', 59147 33863 fn: function(el) { 59148 33864 return { @@ -59152,7 +33868,7 @@ var implementations = [{ 59152 33868 }; 59153 33869 }, 59154 33870 }, {59155 -1 name: 'axe (4.2.3)',-1 33871 name: 'axe (4.4.3)', 59156 33872 url: 'https://github.com/dequelabs/axe-core', 59157 33873 fn: function(el) { 59158 33874 axe._tree = axe.utils.getFlattenedTree(document.body); @@ -59236,4 +33952,4 @@ try { 59236 33952 }); 59237 33953 } 59238 3395459239 -1 },{"./axs":210,"aria-api":194,"axe-core":200,"dom-accessibility-api":205,"w3c-alternative-text-computation":209}]},{},[211]);-1 33955 },{"./axs":26,"aria-api":9,"axe-core":15,"dom-accessibility-api":20,"w3c-alternative-text-computation":25}]},{},[27]);
diff --git a/fuzz.js b/fuzz.js
@@ -293,7 +293,7 @@ var attrs = require('./attrs');
293 293
294 294 var _getOwner = function(node) {
295 295 if (node.nodeType === node.ELEMENT_NODE && node.id) {
296 -1 var owner = document.querySelector('[aria-owns~="' + node.id + '"]');
-1 296 var owner = document.querySelector('[aria-owns~="' + CSS.escape(node.id) + '"]');
297 297 if (owner) {
298 298 return owner;
299 299 }
@@ -316,7 +316,7 @@ var detectLoop = function(node) {
316 316
317 317 var getOwner = function(node) {
318 318 if (node.nodeType === node.ELEMENT_NODE && node.id) {
319 -1 var owner = document.querySelector('[aria-owns~="' + node.id + '"]');
-1 319 var owner = document.querySelector('[aria-owns~="' + CSS.escape(node.id) + '"]');
320 320 if (owner && !detectLoop(node)) {
321 321 return owner;
322 322 }
@@ -498,62 +498,56 @@ module.exports = {
498 498 };
499 499
500 500 },{"./constants.js":7}],7:[function(require,module,exports){
-1 501 // https://www.w3.org/TR/wai-aria/#state_prop_def
501 502 exports.attributes = {
502 -1 // widget
-1 503 'activedescendant': 'id',
-1 504 'atomic': 'bool',
503 505 'autocomplete': 'token',
-1 506 'busy': 'bool',
504 507 'checked': 'tristate',
-1 508 'colcount': 'int',
-1 509 'colindex': 'int',
-1 510 'colspan': 'int',
-1 511 'controls': 'id-list',
505 512 'current': 'token',
-1 513 'describedby': 'id-list',
-1 514 'details': 'id',
506 515 'disabled': 'bool',
-1 516 'dropeffect': 'token-list',
-1 517 'errormessage': 'id',
507 518 'expanded': 'bool-undefined',
-1 519 'flowto': 'id-list',
-1 520 'grabbed': 'bool-undefined',
508 521 'haspopup': 'token',
509 -1 'hidden': 'bool', // !
-1 522 'hidden': 'bool-undefined',
510 523 'invalid': 'token',
511 524 'keyshortcuts': 'string',
512 525 'label': 'string',
-1 526 'labelledby': 'id-list',
513 527 'level': 'int',
-1 528 'live': 'token',
514 529 'modal': 'bool',
515 530 'multiline': 'bool',
516 531 'multiselectable': 'bool',
517 532 'orientation': 'token',
-1 533 'owns': 'id-list',
518 534 'placeholder': 'string',
-1 535 'posinset': 'int',
519 536 'pressed': 'tristate',
520 537 'readonly': 'bool',
-1 538 'relevant': 'token-list',
521 539 'required': 'bool',
522 540 'roledescription': 'string',
523 -1 'selected': 'bool-undefined',
524 -1 'valuemax': 'number',
525 -1 'valuemin': 'number',
526 -1 'valuenow': 'number',
527 -1 'valuetext': 'string',
528 -1
529 -1 // live
530 -1 'atomic': 'bool',
531 -1 'busy': 'bool',
532 -1 'live': 'token',
533 -1 'relevant': 'token-list',
534 -1
535 -1 // dragndrop
536 -1 'dropeffect': 'token-list',
537 -1 'grabbed': 'bool-undefined',
538 -1
539 -1 // relationship
540 -1 'activedescendant': 'id',
541 -1 'colcount': 'int',
542 -1 'colindex': 'int',
543 -1 'colspan': 'int',
544 -1 'controls': 'id-list',
545 -1 'describedby': 'id-list',
546 -1 'details': 'id',
547 -1 'errormessage': 'id',
548 -1 'flowto': 'id-list',
549 -1 'labelledby': 'id-list',
550 -1 'owns': 'id-list',
551 -1 'posinset': 'int',
552 541 'rowcount': 'int',
553 542 'rowindex': 'int',
554 543 'rowspan': 'int',
-1 544 'selected': 'bool-undefined',
555 545 'setsize': 'int',
556 546 'sort': 'token',
-1 547 'valuemax': 'number',
-1 548 'valuemin': 'number',
-1 549 'valuenow': 'number',
-1 550 'valuetext': 'string',
557 551 };
558 552
559 553 exports.attributeStrongMapping = {
@@ -599,6 +593,7 @@ exports.roles = {
599 593 cell: {
600 594 selectors: ['td'],
601 595 childRoles: ['gridcell', 'rowheader'],
-1 596 nameFromContents: true,
602 597 },
603 598 checkbox: {
604 599 selectors: ['input[type="checkbox"]'],
@@ -824,14 +819,14 @@ exports.roles = {
824 819 selectors: ['tr'],
825 820 nameFromContents: true,
826 821 },
827 -1 rowheader: {
828 -1 selectors: ['th[scope="row"]'],
829 -1 nameFromContents: true,
830 -1 },
831 822 rowgroup: {
832 823 selectors: ['tbody', 'thead', 'tfoot'],
833 824 nameFromContents: true,
834 825 },
-1 826 rowheader: {
-1 827 selectors: ['th[scope="row"]'],
-1 828 nameFromContents: true,
-1 829 },
835 830 scrollbar: {
836 831 defaults: {
837 832 'orientation': 'vertical',
@@ -888,13 +883,11 @@ exports.roles = {
888 883 childRoles: ['combobox', 'listbox', 'menu', 'radiogroup', 'tree'],
889 884 },
890 885 separator: {
-1 886 // assume not focussable because <hr> is not
891 887 selectors: ['hr'],
892 888 childRoles: ['doc-pagebreak'],
893 889 defaults: {
894 890 'orientation': 'horizontal',
895 -1 'valuemin': 0,
896 -1 'valuemax': 100,
897 -1 'valuenow': 50,
898 891 },
899 892 },
900 893 slider: {
@@ -922,12 +915,6 @@ exports.roles = {
922 915 'atomic': true,
923 916 },
924 917 },
925 -1 switch: {
926 -1 nameFromContents: true,
927 -1 defaults: {
928 -1 'checked': false,
929 -1 },
930 -1 },
931 918 structure: {
932 919 childRoles: [
933 920 'application',
@@ -940,6 +927,12 @@ exports.roles = {
940 927 'separator',
941 928 ],
942 929 },
-1 930 switch: {
-1 931 nameFromContents: true,
-1 932 defaults: {
-1 933 'checked': false,
-1 934 },
-1 935 },
943 936 tab: {
944 937 nameFromContents: true,
945 938 defaults: {
@@ -994,7 +987,6 @@ exports.roles = {
994 987 'input',
995 988 'range',
996 989 'row',
997 -1 'separator',
998 990 'tab',
999 991 ],
1000 992 },
@@ -1150,12 +1142,12 @@ module.exports = {
1150 1142 };
1151 1143
1152 1144 },{"./atree.js":5,"./attrs.js":6}],10:[function(require,module,exports){
1153 -1 /*!
-1 1145 /*@license
1154 1146 CalcNames: The AccName Computation Prototype, compute the Name and Description property values for a DOM node
1155 1147 Returns an object with 'name' and 'desc' properties.
1156 1148 Functionality mirrors the steps within the W3C Accessible Name and Description computation algorithm.
1157 -1 http://www.w3.org/TR/accname-aam-1.1/
1158 -1 Authored by Bryan Garaventa, plus refactoring contrabutions by Tobias Bengfort
-1 1149 https://w3c.github.io/accname/
-1 1150 Author: Bryan Garaventa
1159 1151 https://github.com/whatsock/w3c-alternative-text-computation
1160 1152 Distributed under the terms of the Open Source Initiative OSI - MIT License
1161 1153 */
@@ -1166,7 +1158,7 @@ Distributed under the terms of the Open Source Initiative OSI - MIT License
1166 1158 window[nameSpace] = {};
1167 1159 nameSpace = window[nameSpace];
1168 1160 }
1169 -1 nameSpace.getAccNameVersion = "2.55";
-1 1161 nameSpace.getAccNameVersion = "2.59";
1170 1162 // AccName Computation Prototype
1171 1163 nameSpace.getAccName = nameSpace.calcNames = function(
1172 1164 node,
@@ -1186,7 +1178,11 @@ Distributed under the terms of the Open Source Initiative OSI - MIT License
1186 1178 var rootNode = node;
1187 1179 var rootRole = trim(node.getAttribute("role") || "");
1188 1180 // Track nodes to prevent duplicate node reference parsing.
1189 -1 var nodes = [];
-1 1181 // Separating Name and Description to prevent duplicate node references from suppressing one or the other from being fully computed.
-1 1182 var nodes = {
-1 1183 name: [],
-1 1184 desc: []
-1 1185 };
1190 1186 // Track aria-owns references to prevent duplicate parsing.
1191 1187 var owns = [];
1192 1188
@@ -1299,7 +1295,12 @@ Plus roles extended for the Role Parity project.
1299 1295 after: ""
1300 1296 };
1301 1297
1302 -1 if (!skipTo.tag && !skipTo.role && nodes.indexOf(refNode) === -1) {
-1 1298 if (
-1 1299 !skipTo.tag &&
-1 1300 !skipTo.role &&
-1 1301 nodes[!ownedBy.computingDesc ? "name" : "desc"].indexOf(refNode) ===
-1 1302 -1
-1 1303 ) {
1303 1304 // Store the before and after pseudo element 'content' values for the top level DOM node
1304 1305 // Note: If the pseudo element includes block level styling, a space will be added, otherwise inline is asumed and no spacing is added.
1305 1306 cssOP = getCSSText(refNode, null);
@@ -1425,8 +1426,13 @@ Plus roles extended for the Role Parity project.
1425 1426 return result;
1426 1427 }
1427 1428
1428 -1 if (!skipTo.tag && !skipTo.role && nodes.indexOf(node) === -1) {
1429 -1 nodes.push(node);
-1 1429 if (
-1 1430 !skipTo.tag &&
-1 1431 !skipTo.role &&
-1 1432 nodes[!ownedBy.computingDesc ? "name" : "desc"].indexOf(node) ===
-1 1433 -1
-1 1434 ) {
-1 1435 nodes[!ownedBy.computingDesc ? "name" : "desc"].push(node);
1430 1436 } else {
1431 1437 // Abort if this node has already been processed.
1432 1438 return result;
@@ -1443,8 +1449,14 @@ Plus roles extended for the Role Parity project.
1443 1449 };
1444 1450
1445 1451 var parent = refNode === node ? node : node.parentNode;
1446 -1 if (!skipTo.tag && !skipTo.role && nodes.indexOf(parent) === -1) {
1447 -1 nodes.push(parent);
-1 1452 if (
-1 1453 !skipTo.tag &&
-1 1454 !skipTo.role &&
-1 1455 nodes[!ownedBy.computingDesc ? "name" : "desc"].indexOf(
-1 1456 parent
-1 1457 ) === -1
-1 1458 ) {
-1 1459 nodes[!ownedBy.computingDesc ? "name" : "desc"].push(parent);
1448 1460 // Store the before and after pseudo element 'content' values for the current node container element
1449 1461 // Note: If the pseudo element includes block level styling, a space will be added, otherwise inline is asumed and no spacing is added.
1450 1462 cssO = getCSSText(parent, refNode);
@@ -1493,6 +1505,17 @@ Plus roles extended for the Role Parity project.
1493 1505 (!skipTo.tag && !skipTo.role && node.getAttribute("title")) ||
1494 1506 "";
1495 1507
-1 1508 // Added to prevent name on generic elements.
-1 1509 // https://www.w3.org/TR/wai-aria-1.2/#generic
-1 1510 var isGeneric =
-1 1511 node === rootNode &&
-1 1512 !nRole &&
-1 1513 genericElements.indexOf(nTag) !== -1;
-1 1514 if (isGeneric) {
-1 1515 // Abort since an implicitly generic rootNode cannot have a name
-1 1516 return result;
-1 1517 }
-1 1518
1496 1519 var isNativeFormField = nativeFormFields.indexOf(nTag) !== -1;
1497 1520 var isNativeButton = ["input"].indexOf(nTag) !== -1;
1498 1521 var isRangeWidgetRole = rangeWidgetRoles.indexOf(nRole) !== -1;
@@ -1524,6 +1547,32 @@ Plus roles extended for the Role Parity project.
1524 1547 ownedBy[node.id].target === node))
1525 1548 );
1526 1549
-1 1550 // Check for non-empty value of aria-labelledby on current node, follow each ID ref, then stop and process no deeper.
-1 1551 if (!stop && !skipTo.tag && !skipTo.role && aLabelledby) {
-1 1552 ids = aLabelledby.split(/\s+/);
-1 1553 parts = [];
-1 1554 for (i = 0; i < ids.length; i++) {
-1 1555 element = docO.getElementById(ids[i]);
-1 1556 // Also prevent the current form field from having its value included in the naming computation if nested as a child of label
-1 1557 parts.push(
-1 1558 walk(element, true, skip, [node], element === refNode, {
-1 1559 ref: ownedBy,
-1 1560 top: element
-1 1561 }).name
-1 1562 );
-1 1563 }
-1 1564 // Check for blank value, since whitespace chars alone are not valid as a name
-1 1565 name = trim(parts.join(" "));
-1 1566
-1 1567 if (trim(name)) {
-1 1568 hasName = true;
-1 1569 hLabel = true;
-1 1570 hasLabel = true;
-1 1571 // Abort further recursion if name is valid.
-1 1572 result.skip = true;
-1 1573 }
-1 1574 }
-1 1575
1527 1576 // Check for non-empty value of aria-describedby/description if current node equals reference node, follow each ID ref, then stop and process no deeper.
1528 1577 if (
1529 1578 !stop &&
@@ -1542,7 +1591,8 @@ Plus roles extended for the Role Parity project.
1542 1591 parts.push(
1543 1592 walk(element, true, false, [node], false, {
1544 1593 ref: ownedBy,
1545 -1 top: element
-1 1594 top: element,
-1 1595 computingDesc: true
1546 1596 }).name
1547 1597 );
1548 1598 }
@@ -1557,32 +1607,6 @@ Plus roles extended for the Role Parity project.
1557 1607 }
1558 1608 }
1559 1609
1560 -1 // Check for non-empty value of aria-labelledby on current node, follow each ID ref, then stop and process no deeper.
1561 -1 if (!stop && !skipTo.tag && !skipTo.role && aLabelledby) {
1562 -1 ids = aLabelledby.split(/\s+/);
1563 -1 parts = [];
1564 -1 for (i = 0; i < ids.length; i++) {
1565 -1 element = docO.getElementById(ids[i]);
1566 -1 // Also prevent the current form field from having its value included in the naming computation if nested as a child of label
1567 -1 parts.push(
1568 -1 walk(element, true, skip, [node], element === refNode, {
1569 -1 ref: ownedBy,
1570 -1 top: element
1571 -1 }).name
1572 -1 );
1573 -1 }
1574 -1 // Check for blank value, since whitespace chars alone are not valid as a name
1575 -1 name = trim(parts.join(" "));
1576 -1
1577 -1 if (trim(name)) {
1578 -1 hasName = true;
1579 -1 hLabel = true;
1580 -1 hasLabel = true;
1581 -1 // Abort further recursion if name is valid.
1582 -1 result.skip = true;
1583 -1 }
1584 -1 }
1585 -1
1586 1610 // Otherwise, if current node has a non-empty aria-label then set as name and process no deeper within the branch.
1587 1611 if (
1588 1612 !skipTo.tag &&
@@ -1835,32 +1859,6 @@ Plus roles extended for the Role Parity project.
1835 1859 skip = true;
1836 1860 }
1837 1861
1838 -1 var isFigure =
1839 -1 !skipTo.tag &&
1840 -1 !skipTo.role &&
1841 -1 !hasName &&
1842 -1 (nRole === "figure" || (!nRole && nTag === "figure"));
1843 -1
1844 -1 // Otherwise, if name is still empty and is a standard figure element with a non-empty associated figcaption element as the first or last child node, process caption with same naming computation algorithm.
1845 -1 // Plus do the same for role="figure" with embedded role="caption", or a combination of these.
1846 -1 if (isFigure) {
1847 -1 fChild =
1848 -1 firstChild(node, ["figcaption"], ["caption"]) ||
1849 -1 lastChild(node, ["figcaption"], ["caption"]) ||
1850 -1 false;
1851 -1 if (fChild) {
1852 -1 name = trim(
1853 -1 walk(fChild, stop, false, [], false, {
1854 -1 ref: ownedBy,
1855 -1 top: fChild
1856 -1 }).name
1857 -1 );
1858 -1 }
1859 -1 if (trim(name)) {
1860 -1 hasName = true;
1861 -1 }
1862 -1 }
1863 -1
1864 1862 // Otherwise, if name is still empty and the root node and the current node are the same and node is an svg element, then parse the content of the title element to set the name and the desc element to set the description.
1865 1863 if (!skipTo.tag && !skipTo.role && nTag === "svg") {
1866 1864 var svgT = node.querySelector("title") || false;
@@ -2291,6 +2289,7 @@ Plus roles extended for the Role Parity project.
2291 2289 tags: ["legend", "caption", "figcaption"]
2292 2290 };
2293 2291
-1 2292 var genericElements = ["div", "span"];
2294 2293 var nativeFormFields = ["button", "input", "select", "textarea"];
2295 2294 var rangeWidgetRoles = ["scrollbar", "slider", "spinbutton"];
2296 2295 var editWidgetRoles = ["searchbox", "textbox"];
@@ -2705,10 +2704,10 @@ Plus roles extended for the Role Parity project.
2705 2704 var accName = trim(accProps.name.replace(/\s+/g, " "));
2706 2705 var accDesc = trim(accProps.title.replace(/\s+/g, " "));
2707 2706
2708 -1 if (accName === accDesc) {
2709 -1 // If both Name and Description properties match, then clear the Description property value.
2710 -1 accDesc = "";
2711 -1 }
-1 2707 // if (accName === accDesc) {
-1 2708 // If both Name and Description properties match, then clear the Description property value. (Ideal but not in the spec so commented out.)
-1 2709 // accDesc = "";
-1 2710 // }
2712 2711
2713 2712 props.hasUpperCase =
2714 2713 rootRole && rootRole !== rootRole.toLowerCase() ? true : false;
@@ -2716,7 +2715,10 @@ Plus roles extended for the Role Parity project.
2716 2715 props.desc = accDesc;
2717 2716
2718 2717 // Clear track variables
2719 -1 nodes = [];
-1 2718 nodes = {
-1 2719 name: [],
-1 2720 desc: []
-1 2721 };
2720 2722 owns = [];
2721 2723 } catch (e) {
2722 2724 props.error = e;