You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5433 lines
188 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  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. (function (Buffer){
  3. exports.code = new Buffer("AGFzbQEAAAABPApgAn9/AGABfwBgAX8Bf2ACf38Bf2ADf39/AX9gA39/fwBgA39+fwBgAn9+AGAEf39/fwBgBX9/f39/AAIQAQNlbnYGbWVtb3J5AgDoBwNoZwABAgEDAwQEBQYHCAUFBQAABQAAAAEFBQAABQAAAAEFAAIBAAAFAAUAAAAIAQIAAgUICQgABQkDAAUFBQUAAgUFCAAIAgEBAAUFBQAAAAMAAgEAAAUABQAAAAgBAgACBQgJCAAFCQUHjAleCGludF9jb3B5AAAIaW50X3plcm8AAQdpbnRfb25lAAMKaW50X2lzWmVybwACBmludF9lcQAEB2ludF9ndGUABQdpbnRfYWRkAAYHaW50X3N1YgAHB2ludF9tdWwACAdpbnRfZGl2AAsOaW50X2ludmVyc2VNb2QADAdmMW1fYWRkAA0HZjFtX3N1YgAOB2YxbV9uZWcADwtmMW1fbVJlZHVjdAAQB2YxbV9tdWwAERJmMW1fZnJvbU1vbnRnb21lcnkAExBmMW1fdG9Nb250Z29tZXJ5ABILZjFtX2ludmVyc2UAFAhmMW1fY29weQAACGYxbV96ZXJvAAEKZjFtX2lzWmVybwACBmYxbV9lcQAEB2YxbV9vbmUAFQdmcm1fYWRkABYHZnJtX3N1YgAXB2ZybV9uZ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2cyX211bHRpZXhwAGEMZzJfbXVsdGlleHAyAGUJdGVzdEFkZEcxAGYKlXVnKgAgASAAKQMANwMAIAEgACkDCDcDCCABIAApAxA3AxAgASAAKQMYNwMYCx4AIABCADcDACAAQgA3AwggAEIANwMQIABCADcDGAszACAAKQMYUARAIAApAxBQBEAgACkDCFAEQCAAKQMAUA8FQQAPCwVBAA8LBUEADwtBAA8LHgAgAEIBNwMAIABCADcDCCAAQgA3AxAgAEIANwMYC0cAIAApAxggASkDGFEEQCAAKQMQIAEpAxBRBEAgACkDCCABKQMIUQRAIAApAwAgASkDAFEPBUEADwsFQQAPCwVBAA8LQQAPC30AIAApAxggASkDGFQEQEEADwUgACkDGCABKQMYVgRAQQEPBSAAKQMQIAEpAxBUBEBBAA8FIAApAxAgASkDEFYEQEEBDwUgACkDCCABKQMIVARAQQAPBSAAKQMIIAEpAwhWBEBBAQ8FIAApAwAgASkDAFoPCwsLCwsLQQAPC9QBAQF+IAA1AgAgATUCAHwhAyACIAM+AgAgADUCBCABNQIEfCADQiCIfCEDIAIgAz4CBCAANQIIIAE1Agh8IANCIIh8IQMgAiADPgIIIAA1AgwgATUCDHwgA0IgiHwhAyACIAM+AgwgADUCECABNQIQfCADQiCIfCEDIAIgAz4CECAANQIUIAE1AhR8IANCIIh8IQMgAiADPgIUIAA1AhggATUCGHwgA0IgiHwhAyACIAM+AhggADUCHCABNQIcfCADQiCIfCEDIAIgAz4CHCADQiCIpwuMAgEBfiAANQIAIAE1AgB9IQMgAiADQv////8Pgz4CACAANQIEIAE1AgR9IANCIId8IQMgAiADQv////8Pgz4CBCAANQIIIAE1Agh9IANCIId8IQMgAiADQv////8Pgz4CCCAANQIMIAE1Agx9IANCIId8IQMgAiADQv////8Pgz4CDCAANQIQIAE1AhB9IANCIId8IQMgAiADQv////8Pgz4CECAANQIUIAE1AhR9IANCIId8IQMgAiADQv////8Pgz4CFCAANQIYIAE1Ahh9IANCIId8IQMgAiADQv////8Pgz4CGCAANQIcIAE1Ahx9IANCIId8IQMgAiADQv////8Pgz4CHCADQiCHpwv0EAEBfkEoIAA1AgAgATUCAH43AwBBKCAANQIAIAE1AgR+NwMIQSggADUCACABNQIIfjcDEEEoIAA1AgAgATUCDH43AxhBKCAANQIAIAE1AhB+NwMgQSggADUCACABNQIUfjcDKEEoIAA1AgAgATUCGH43AzBBKCAANQIAIAE1Ahx+NwM4QSggADUCBCABNQIAfjcDQEEoIAA1AgQgATUCBH43A0hBKCAANQIEIAE1Agh+NwNQQSggADUCBCABNQIMfjcDWEEoIAA1AgQgATUCEH43A2BBKCAANQIEIAE1AhR+NwNoQSggADUCBCABNQIYfjcDcEEoIAA1AgQgATUCHH43A3hBKCAANQIIIAE1AgB+NwOAAUEoIAA1AgggATUCBH43A4gBQSggADUCCCABNQIIfjcDkAFBKCAANQIIIAE1Agx+NwOYAUEoIAA1AgggATUCEH43A6ABQSggADUCCCABNQIUfjcDqAFBKCAANQIIIAE1Ahh+NwOwAUEoIAA1AgggATUCHH43A7gBQSggADUCDCABNQIAfjcDwAFBKCAANQIMIAE1AgR+NwPIAUEoIAA1AgwgATUCCH43A9ABQSggADUCDCABNQIMfjcD2AFBKCAANQIMIAE1AhB+NwPgAUEoIAA1AgwgATUCFH43A+gBQSggADUCDCABNQIYfjcD8AFBKCAANQIMIAE1Ahx+NwP4AUEoIAA1AhAgATUCAH43A4ACQSggADUCECABNQIEfjcDiAJBKCAANQIQIAE1Agh+NwOQAkEoIAA1AhAgATUCDH43A5gCQSggADUCECABNQIQfjcDoAJBKCAANQIQIAE1AhR+NwOoAkEoIAA1AhAgATUCGH43A7ACQSggADUCECABNQIcfjcDuAJBKCAANQIUIAE1AgB+NwPAAkEoIAA1AhQgATUCBH43A8gCQSggADUCFCABNQIIfjcD0AJBKCAANQIUIAE1Agx+NwPYAkEoIAA1AhQgATUCEH43A+ACQSggADUCFCABNQIUfjcD6AJBKCAANQIUIAE1Ahh+NwPwAkEoIAA1AhQgATUCHH43A/gCQSggADUCGCABNQIAfj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AM+AiQgADUCKCADQiCIfEHoBzUCECAEfnwhAyAAIAM+AiggADUCLCADQiCIfEHoBzUCFCAEfnwhAyAAIAM+AiwgADUCMCADQiCIfEHoBzUCGCAEfnwhAyAAIAM+AjAgADUCNCADQiCIfEHoBzUCHCAEfnwhAyAAIAM+AjRB6AggA0IgiD4CGEIAIQMgADUCHCACfkL/////D4MhBCAANQIcIANCIIh8QegHNQIAIAR+fCEDIAAgAz4CHCAANQIgIANCIIh8QegHNQIEIAR+fCEDIAAgAz4CICAANQIkIANCIIh8QegHNQIIIAR+fCEDIAAgAz4CJCAANQIoIANCIIh8QegHNQIMIAR+fCEDIAAgAz4CKCAANQIsIANCIIh8QegHNQIQIAR+fCEDIAAgAz4CLCAANQIwIANCIIh8QegHNQIUIAR+fCEDIAAgAz4CMCAANQI0IANCIIh8QegHNQIYIAR+fCEDIAAgAz4CNCAANQI4IANCIIh8QegHNQIcIAR+fCEDIAAgAz4COEHoCCADQiCIPgIcQegIIABBIGogARANCxIAIAAgAUHoDBAIQegMIAIQEAsLACAAQYgIIAEQEQsVACAAQagNEABByA0QAUGoDSABEBALFwAgACABEBMgAUHoByABEAwgASABEBILCQBBqAggABAACywAIAAgASACEAYEQCACQegNIAIQBxoFIAJB6A0QBQRAIAJB6A0gAhAHGgsLCxcAIAAgASACEAcEQCACQegNIAIQBhoLCxQAIAAQAkUEQEHoDSAAIAEQBxoLC5wRAwF+AX4BfkL/////DiECQgAhAyAANQIAIAJ+Qv////8PgyEEIAA1AgAgA0IgiHxB6A01AgAgBH58IQMgACADPgIAIAA1AgQgA0IgiHxB6A01AgQgBH58IQMgACADPgIEIAA1AgggA0IgiHxB6A01AgggBH58IQMgACADPgIIIAA1AgwgA0IgiHxB6A01AgwgBH58IQMgACADPgIMIAA1AhAgA0IgiHxB6A01AhAgBH58IQMgACADPgIQIAA1AhQgA0IgiHxB6A01AhQgBH58IQMgACADPgIUIAA1AhggA0IgiHxB6A01AhggBH58IQMgACADPgIYIAA1AhwgA0IgiHxB6A01AhwgBH58IQMgACADPgIcQegOIANCIIg+AgBCACEDIAA1AgQgAn5C/////w+DIQQgADUCBCADQiCIfEHoDTUCACAEfnwhAyAAIAM+AgQgADUCCCADQiCIfEHoDTUCBCAEfnwhAyAAIAM+AgggADUCDCADQiCIfEHoDTUCCCAEfnwhAyAAIAM+AgwgADUCECADQiCIfEHoDTUCDCAEfnwhAyAAIAM+AhAgADUCFCADQiCIfEHoDTUCECAEfnwhAyAAIAM+AhQgADUCGCADQiCIfEHoDTUCFCAEfnwhAyAAIAM+AhggADUCHCADQiCIfEHoDTUCGCAEfnwhAyAAIAM+AhwgADUCICADQiCIfEHoDTUCHCAEfnwhAyAAIAM+AiBB6A4gA0IgiD4CBEIAIQMgADUCCCACfkL/////D4MhBCAANQIIIANCIIh8QegNNQIAIAR+fCEDIAAgAz4CCCAANQIMIANCIIh8QegNNQIEIAR+fCEDIAAgAz4CDCAANQIQIANCIIh8QegNNQIIIAR+fCEDIAAgAz4CECAANQIUIANCIIh8QegNNQIMIAR+fCEDIAAgAz4CFCAANQIYIANCIIh8QegNNQIQIAR+fCEDIAAgAz4CGCAANQIcIANCIIh8QegNNQIUIAR+fCEDIAAgAz4CHCAANQIgIANCIIh8QegNNQIYIAR+fCEDIAAgAz4CICAANQIkIANCIIh8QegNNQIcIAR+fCEDIAAgAz4CJEHoDiADQiCIPgIIQgAhAyAANQIMIAJ+Qv////8PgyEEIAA1AgwgA0IgiHxB6A01AgAgBH58IQMgACADPgIMIAA1AhAgA0IgiHxB6A01AgQgBH58IQMgACADPgIQIAA1AhQgA0IgiHxB6A01AgggBH58IQMgACADPgIUIAA1AhggA0IgiHxB6A01AgwgBH58IQMgACADPgIYIAA1AhwgA0IgiHxB6A01AhAgBH58IQMgACADPgIcIAA1AiAgA0IgiHxB6A01AhQgBH58IQMgACADPgIgIAA1AiQgA0IgiHxB6A01AhggBH58IQMgACADPgIkIAA1AiggA0IgiHxB6A01AhwgBH58IQMgACADPgIoQegOIANCIIg+AgxCACEDIAA1AhAgAn5C/////w+DIQQgADUCECADQiCIfEHoDTUCACAEfnwhAyAAIAM+AhAgADUCFCADQiCIfEHoDTUCBCAEfnwhAyAAIAM+AhQgADUCGCADQiCIfEHoDTUCCCAEfnwhAyAAIAM+AhggADUCHCADQiCIfEHoDTUCDCAEfnwhAyAAIAM+AhwgADUCICADQiCIfEHoDTUCECAEfnwhAyAAIAM+AiAgADUCJCADQiCIfEHoDTUCFCAEfnwhAyAAIAM+AiQgADUCKCADQiCIfEHoDTUCGCAEfnwhAyAAIAM+AiggADUCLCADQiCIfEHoDTUCHCAEfnwhAyAAIAM+AixB6A4gA0IgiD4CEEIAIQMgADUCFCACfkL/////D4MhBCAANQIUIANCIIh8QegNNQIAIAR+fCEDIAAgAz4CFCAANQIYIANCIIh8QegNNQIEIAR+fCEDIAAgAz4CGCAANQIcIANCIIh8QegNNQIIIAR+fCEDIAAgAz4CHCAANQIgIANCIIh8QegNNQIMIAR+fCEDIAAgAz4CICAANQIkIANCIIh8QegNNQIQIAR+fCEDIAAgAz4CJCAANQIoIANCIIh8QegNNQIUIAR+fCEDIAAgAz4CKCAANQIsIANCIIh8QegNNQIYIAR+fCEDIAAgAz4CLCAANQIwIANCIIh8QegNNQIcIAR+fCEDIAAgAz4CMEHoDiADQiCIPgIUQgAhAyAANQIYIAJ+Qv////8PgyEEIAA1AhggA0IgiHxB6A01AgAgBH58IQMgACADPgIYIAA1AhwgA0IgiHxB6A01AgQgBH58IQMgACADPgIcIAA1AiAgA0IgiHxB6A01AgggBH58IQMgACADPgIgIAA1AiQgA0IgiHxB6A01AgwgBH58IQMgACADPgIkIAA1AiggA0IgiHxB6A01AhAgBH58IQMgACADPgIoIAA1AiwgA0IgiHxB6A01AhQgBH58IQMgACADPgIsIAA1AjAgA0IgiHxB6A01AhggBH58IQMgACADPgIwIAA1AjQgA0IgiHxB6A01AhwgBH58IQMgACADPgI0QegOIANCIIg+AhhCACEDIAA1AhwgAn5C/////w+DIQQgADUCH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ESABQSBqQYgXQegXEBFByBZB6BYQBARAQcgXQegXEAQEQCAAIAIQJA8LC0HoFkHIFkGIGBAOQegXQcgXQagYEA5BiBhBiBhByBgQDUHIGEHIGEHIGBARQYgYQcgYQegYEBFBqBhBqBhBiBkQDUHIFkHIGEHIGRARQYgZQYgZQagZEBFByBlByBlB6BkQDUGoGUHoGCACEA4gAkHoGSACEA5ByBdB6BhBiBoQEUGIGkGIGkGIGhANQcgZIAIgAkEgahAOIAJBIGpBiBkgAkEgahARIAJBIGpBiBogAkEgahAOIAMgBCACQcAAahANIAJBwABqIAJBwABqIAJBwABqEBEgAkHAAGpBiBYgAkHAAGoQDiACQcAAakGoFiACQcAAahAOIAJBwABqQYgYIAJBwABqEBELIgAgACABEAAgAEEgaiABQSBqEA8gAEHAAGogAUHAAGoQAAsQACABIAIQJiAAIAIgAhAlCyIAIAAgARATIABBIGogAUEgahATIABBwABqIAFBwABqEBMLIgAgACABEBIgAEEgaiABQSBqEBIgAEHAAGogAUHAAGoQEgtPACAAECEEQCABECIFIABBwABqQagaEBRBqBpBqBpByBoQEUGoGkHIGkHoGhARIABByBogARARIABBIGpB6BogAUEgahARIAFBwABqEBULC6cCAgF/AX8gAEGIGxAjIAMQIiACIQQCQANAIARBAWshBCABIARqLQAAIQUgAyADECQgBUGAAU8EQCAFQYABayEFQYgbIAMgAxAlCyADIAMQJCAFQcAATwRAIAVBwABrIQVBiBsgAyADECULIAMgAxAkIAVBIE8EQCAFQSBrIQVBiBsgAyADECULIAMgAxAkIAVBEE8EQCAFQRBrIQVBiBsgAyADECULIAMgAxAkIAVBCE8EQCAFQQhrIQVBiBsgAyADECULIAMgAxAkIAVBBE8EQCAFQQRrIQVBiBsgAyADECULIAMgAxAkIAVBAk8EQCAFQQJrIQVBiBsgAyADECULIAMgAxAkIAVBAU8EQCAFQQFrIQVBiBsgAyADECULIARFDQEMAAsLCysCAX8BfyAAQQV2QQJ0IQFBASAAQR9xdCECIAEgASgC6NsBIAJyNgLo2wELJA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CCAEIAcQGkGItwMgBCAIEBogBUEBaiEFDAALCyAAIAQgABAaIAAgA0EgbGohCCAIIAQgCBAaC0MCAX8BfyAAQQF2IQJBACEBAkADQCACRQ0BIAJBAXYhAiABQQFqIQEMAAsLIABBASABdEcEQAALIAFBHEsEQAALIAELEgEBfyABED4hAyAAIAMgAhA5CxgBAX8gARA+IQMgACADIAIQOSAAIAMQPQtMBAF/AX8BfwF/IAAhBCABIQUgAyEGIAAgAkEgbGohBwJAA0AgBCAHRg0BIAQgBSAGEBogBEEgaiEEIAVBIGohBSAGQSBqIQYMAAsLCy4CAX8BfyAAIQMgACABQSBsaiECAkADQCADIAJGDQEgAxABIANBIGohAwwACwsLjgEGAX8BfwF/AX8BfwF/QQAhBCAAIQYgASEHAkADQCAEIAJGDQEgBigCACEJIAZBBGohBkEAIQUCQANAIAUgCUYNASADIAYoAgBBIGxqIQggBkEEaiEGIAcgBkGotwMQGkGotwMgCCAIEBYgBkEgaiEGIAVBAWohBQwACwsgB0EgaiEHIARBAWohBAwACwsLDgAgABACIABBIGoQAnELDQAgABABIABBIGoQAQsNACAAEBUgAEEgahABCxQAIAAgARAAIABBIGogAUEgahAAC3kAIAAgAUHotwMQESAAQSBqIAFBIGpBiLgDEBEgACAAQSBqQai4AxANIAEgAUEgakHIuAMQDUGouANByLgDQai4AxARQYi4A0HItwMgAhARQei3AyACIAIQDUHotwNBiLgDIAJBIGoQDUGouAMgAkEgaiACQSBqEA4LGwAgACABIAIQDSAAQSBqIAFBIGogAkEgahANCxsAIAAgASACEA4gAEEgaiABQSBqIAJBIGoQDgsUACAAIAEQDyAAQSBqIAFBIGoQDwsUACAAIAEQEiAAQSBqIAFBIGoQEgsUACAAIAEQEyAAQSBqIAFBIGoQEwsVACAAIAEQBCAAQSBqIAFBIGoQBHELaAAgACAAQei4AxARIABBIGogAEEgakGIuQMQEUGIuQNByLcDQai5AxARQei4A0GouQNBqLkDEA5BqLkDQci5AxAUIABByLkDIAEQESAAQSBqQci5AyABQSBqEBEgAUEgaiABQSBqEA8LCgAgAEGAAWoQRAsWACAAEEUgAEHAAGoQRiAAQYABahBFCyQAIAAgARBHIABBwABqIAFBwABqEEcgAEGAAWogAUGAAWoQRwu8AgAgABBQBEAgACABEFIPCyAAIABB6LkDEEggAEHAAGogAEHAAGpBqLoDEEhBqLoDQai6A0HougMQSCAAQai6A0GouwMQSUGouwNBqLsDQai7AxBIQai7A0HouQNBqLsDEEpBqLsDQei6A0GouwMQSkGouwNBqLsDQai7AxBJQei5A0HouQNB6LsDEElB6LsDQei5A0HouwMQSUHouwNB6LsDQai8AxBIIABBwABqIABBgAFqQei8AxBIQai7A0GouwMgARBJQai8AyABIAEQSkHougNB6LoDQai9AxBJQai9A0GovQNBqL0DEElBqL0DQai9A0GovQMQSUGouwMgASABQcAAahBKIAFBwABqQei7AyABQcAAahBIIAFBwABqQai9AyABQcAAahBKQei8A0HovAMgAUGAAWoQSQvvAwIBfwF/IABBgAFqIQMgAUGAAWohBCAAEFAEQCABIAIQUg8LIAEQUARAIAAgAhBSDwsgAyADQei9AxBIIAQgBEGovgMQSCAAQai+A0HovgMQSCABQei9A0GovwMQSCADQei9A0HovwMQSCAEQai+A0GowAMQSCAAQcAAakGowANB6MADEEggAUHAAGpB6L8DQajBAxBIQei+A0GovwMQTgRAQejAA0GowQMQTgRAIAAgAhBTDwsLQai/A0HovgNB6MEDEEpBqMEDQejAA0GowgMQSkHowQNB6MEDQejCAxBJQejCA0HowgNB6MIDEEhB6MEDQejCA0GowwMQSEGowgNBqMIDQejDAxBJQei+A0HowgNB6MQDEEhB6MMDQejDA0GoxAMQSEHoxANB6MQDQajFAxBJQajEA0GowwMgAhBKIAJBqMUDIAIQSkHowANBqMMDQejFAxBIQejFA0HoxQNB6MUDEElB6MQDIAIgAkHAAGoQSiACQcAAakHowwMgAkHAAGoQSCACQcAAakHoxQMgAkHAAGoQSiADIAQgAkGAAWoQSSACQYABaiACQYABaiACQYABahBIIAJBgAFqQei9AyACQYABahBKIAJB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LCwsLCwuIDAwMDAwMDEwMDAyMDIyMjAwMDQwNDQ0MDQ0NDQ0NDYwMDA4MDg4ODA4ODg4ODg6MDg4ODg4ODw4ODg8ODw8PAAQcjLBguAAgAAAAEAAQIBAAECAQQBAgMAAQIBBAECAwgBAgMEBQYDAAECAQQBAgMIAQIDBAUGAxABAgMEBQYDCAkKAwwFBgcAAQIBBAECAwgBAgMEBQYDEAECAwQFBgMICQoDDAUGByABAgMEBQYDCAkKAwwFBgcQERIDFAUGBxgJCgsMDQ4HAAECAQQBAgMIAQIDBAUGAxABAgMEBQYDCAkKAwwFBgcgAQIDBAUGAwgJCgMMBQYHEBESAxQFBgcYCQoLDA0OB0ABAgMEBQYDCAkKAwwFBgcQERIDFAUGBxgJCgsMDQ4HICEiAyQFBgcoCQoLDA0OBzAREhMUFRYHGBkaCxwNDg8=", "base64");
  4. exports.pq = 1000;
  5. exports.pr = 1768;
  6. }).call(this,require("buffer").Buffer)
  7. },{"buffer":10}],2:[function(require,module,exports){
  8. /*
  9. Copyright 2019 0KIMS association.
  10. This file is part of websnark (Web Assembly zkSnark Prover).
  11. websnark is a free software: you can redistribute it and/or modify it
  12. under the terms of the GNU General Public License as published by
  13. the Free Software Foundation, either version 3 of the License, or
  14. (at your option) any later version.
  15. websnark is distributed in the hope that it will be useful, but WITHOUT
  16. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  17. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  18. License for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with websnark. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /* globals window */
  23. const buildGroth16 = require("./src/groth16.js");
  24. buildGroth16().then( (groth16) => {
  25. window.groth16 = groth16;
  26. window.genZKSnarkProof = function(witness, provingKey, cb) {
  27. const p = groth16.proof(witness, provingKey);
  28. if (cb) {
  29. p.then( (proof) => {
  30. cb(null, proof);
  31. }, (err) => {
  32. cb(err);
  33. });
  34. } else {
  35. return p;
  36. }
  37. };
  38. });
  39. },{"./src/groth16.js":4}],3:[function(require,module,exports){
  40. var bigInt = (function (undefined) {
  41. "use strict";
  42. var BASE = 1e7,
  43. LOG_BASE = 7,
  44. MAX_INT = 9007199254740992,
  45. MAX_INT_ARR = smallToArray(MAX_INT),
  46. DEFAULT_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
  47. var supportsNativeBigInt = typeof BigInt === "function";
  48. function Integer(v, radix, alphabet, caseSensitive) {
  49. if (typeof v === "undefined") return Integer[0];
  50. if (typeof radix !== "undefined") return +radix === 10 && !alphabet ? parseValue(v) : parseBase(v, radix, alphabet, caseSensitive);
  51. return parseValue(v);
  52. }
  53. function BigInteger(value, sign) {
  54. this.value = value;
  55. this.sign = sign;
  56. this.isSmall = false;
  57. }
  58. BigInteger.prototype = Object.create(Integer.prototype);
  59. function SmallInteger(value) {
  60. this.value = value;
  61. this.sign = value < 0;
  62. this.isSmall = true;
  63. }
  64. SmallInteger.prototype = Object.create(Integer.prototype);
  65. function NativeBigInt(value) {
  66. this.value = value;
  67. }
  68. NativeBigInt.prototype = Object.create(Integer.prototype);
  69. function isPrecise(n) {
  70. return -MAX_INT < n && n < MAX_INT;
  71. }
  72. function smallToArray(n) { // For performance reasons doesn't reference BASE, need to change this function if BASE changes
  73. if (n < 1e7)
  74. return [n];
  75. if (n < 1e14)
  76. return [n % 1e7, Math.floor(n / 1e7)];
  77. return [n % 1e7, Math.floor(n / 1e7) % 1e7, Math.floor(n / 1e14)];
  78. }
  79. function arrayToSmall(arr) { // If BASE changes this function may need to change
  80. trim(arr);
  81. var length = arr.length;
  82. if (length < 4 && compareAbs(arr, MAX_INT_ARR) < 0) {
  83. switch (length) {
  84. case 0: return 0;
  85. case 1: return arr[0];
  86. case 2: return arr[0] + arr[1] * BASE;
  87. default: return arr[0] + (arr[1] + arr[2] * BASE) * BASE;
  88. }
  89. }
  90. return arr;
  91. }
  92. function trim(v) {
  93. var i = v.length;
  94. while (v[--i] === 0);
  95. v.length = i + 1;
  96. }
  97. function createArray(length) { // function shamelessly stolen from Yaffle's library https://github.com/Yaffle/BigInteger
  98. var x = new Array(length);
  99. var i = -1;
  100. while (++i < length) {
  101. x[i] = 0;
  102. }
  103. return x;
  104. }
  105. function truncate(n) {
  106. if (n > 0) return Math.floor(n);
  107. return Math.ceil(n);
  108. }
  109. function add(a, b) { // assumes a and b are arrays with a.length >= b.length
  110. var l_a = a.length,
  111. l_b = b.length,
  112. r = new Array(l_a),
  113. carry = 0,
  114. base = BASE,
  115. sum, i;
  116. for (i = 0; i < l_b; i++) {
  117. sum = a[i] + b[i] + carry;
  118. carry = sum >= base ? 1 : 0;
  119. r[i] = sum - carry * base;
  120. }
  121. while (i < l_a) {
  122. sum = a[i] + carry;
  123. carry = sum === base ? 1 : 0;
  124. r[i++] = sum - carry * base;
  125. }
  126. if (carry > 0) r.push(carry);
  127. return r;
  128. }
  129. function addAny(a, b) {
  130. if (a.length >= b.length) return add(a, b);
  131. return add(b, a);
  132. }
  133. function addSmall(a, carry) { // assumes a is array, carry is number with 0 <= carry < MAX_INT
  134. var l = a.length,
  135. r = new Array(l),
  136. base = BASE,
  137. sum, i;
  138. for (i = 0; i < l; i++) {
  139. sum = a[i] - base + carry;
  140. carry = Math.floor(sum / base);
  141. r[i] = sum - carry * base;
  142. carry += 1;
  143. }
  144. while (carry > 0) {
  145. r[i++] = carry % base;
  146. carry = Math.floor(carry / base);
  147. }
  148. return r;
  149. }
  150. BigInteger.prototype.add = function (v) {
  151. var n = parseValue(v);
  152. if (this.sign !== n.sign) {
  153. return this.subtract(n.negate());
  154. }
  155. var a = this.value, b = n.value;
  156. if (n.isSmall) {
  157. return new BigInteger(addSmall(a, Math.abs(b)), this.sign);
  158. }
  159. return new BigInteger(addAny(a, b), this.sign);
  160. };
  161. BigInteger.prototype.plus = BigInteger.prototype.add;
  162. SmallInteger.prototype.add = function (v) {
  163. var n = parseValue(v);
  164. var a = this.value;
  165. if (a < 0 !== n.sign) {
  166. return this.subtract(n.negate());
  167. }
  168. var b = n.value;
  169. if (n.isSmall) {
  170. if (isPrecise(a + b)) return new SmallInteger(a + b);
  171. b = smallToArray(Math.abs(b));
  172. }
  173. return new BigInteger(addSmall(b, Math.abs(a)), a < 0);
  174. };
  175. SmallInteger.prototype.plus = SmallInteger.prototype.add;
  176. NativeBigInt.prototype.add = function (v) {
  177. return new NativeBigInt(this.value + parseValue(v).value);
  178. }
  179. NativeBigInt.prototype.plus = NativeBigInt.prototype.add;
  180. function subtract(a, b) { // assumes a and b are arrays with a >= b
  181. var a_l = a.length,
  182. b_l = b.length,
  183. r = new Array(a_l),
  184. borrow = 0,
  185. base = BASE,
  186. i, difference;
  187. for (i = 0; i < b_l; i++) {
  188. difference = a[i] - borrow - b[i];
  189. if (difference < 0) {
  190. difference += base;
  191. borrow = 1;
  192. } else borrow = 0;
  193. r[i] = difference;
  194. }
  195. for (i = b_l; i < a_l; i++) {
  196. difference = a[i] - borrow;
  197. if (difference < 0) difference += base;
  198. else {
  199. r[i++] = difference;
  200. break;
  201. }
  202. r[i] = difference;
  203. }
  204. for (; i < a_l; i++) {
  205. r[i] = a[i];
  206. }
  207. trim(r);
  208. return r;
  209. }
  210. function subtractAny(a, b, sign) {
  211. var value;
  212. if (compareAbs(a, b) >= 0) {
  213. value = subtract(a, b);
  214. } else {
  215. value = subtract(b, a);
  216. sign = !sign;
  217. }
  218. value = arrayToSmall(value);
  219. if (typeof value === "number") {
  220. if (sign) value = -value;
  221. return new SmallInteger(value);
  222. }
  223. return new BigInteger(value, sign);
  224. }
  225. function subtractSmall(a, b, sign) { // assumes a is array, b is number with 0 <= b < MAX_INT
  226. var l = a.length,
  227. r = new Array(l),
  228. carry = -b,
  229. base = BASE,
  230. i, difference;
  231. for (i = 0; i < l; i++) {
  232. difference = a[i] + carry;
  233. carry = Math.floor(difference / base);
  234. difference %= base;
  235. r[i] = difference < 0 ? difference + base : difference;
  236. }
  237. r = arrayToSmall(r);
  238. if (typeof r === "number") {
  239. if (sign) r = -r;
  240. return new SmallInteger(r);
  241. } return new BigInteger(r, sign);
  242. }
  243. BigInteger.prototype.subtract = function (v) {
  244. var n = parseValue(v);
  245. if (this.sign !== n.sign) {
  246. return this.add(n.negate());
  247. }
  248. var a = this.value, b = n.value;
  249. if (n.isSmall)
  250. return subtractSmall(a, Math.abs(b), this.sign);
  251. return subtractAny(a, b, this.sign);
  252. };
  253. BigInteger.prototype.minus = BigInteger.prototype.subtract;
  254. SmallInteger.prototype.subtract = function (v) {
  255. var n = parseValue(v);
  256. var a = this.value;
  257. if (a < 0 !== n.sign) {
  258. return this.add(n.negate());
  259. }
  260. var b = n.value;
  261. if (n.isSmall) {
  262. return new SmallInteger(a - b);
  263. }
  264. return subtractSmall(b, Math.abs(a), a >= 0);
  265. };
  266. SmallInteger.prototype.minus = SmallInteger.prototype.subtract;
  267. NativeBigInt.prototype.subtract = function (v) {
  268. return new NativeBigInt(this.value - parseValue(v).value);
  269. }
  270. NativeBigInt.prototype.minus = NativeBigInt.prototype.subtract;
  271. BigInteger.prototype.negate = function () {
  272. return new BigInteger(this.value, !this.sign);
  273. };
  274. SmallInteger.prototype.negate = function () {
  275. var sign = this.sign;
  276. var small = new SmallInteger(-this.value);
  277. small.sign = !sign;
  278. return small;
  279. };
  280. NativeBigInt.prototype.negate = function () {
  281. return new NativeBigInt(-this.value);
  282. }
  283. BigInteger.prototype.abs = function () {
  284. return new BigInteger(this.value, false);
  285. };
  286. SmallInteger.prototype.abs = function () {
  287. return new SmallInteger(Math.abs(this.value));
  288. };
  289. NativeBigInt.prototype.abs = function () {
  290. return new NativeBigInt(this.value >= 0 ? this.value : -this.value);
  291. }
  292. function multiplyLong(a, b) {
  293. var a_l = a.length,
  294. b_l = b.length,
  295. l = a_l + b_l,
  296. r = createArray(l),
  297. base = BASE,
  298. product, carry, i, a_i, b_j;
  299. for (i = 0; i < a_l; ++i) {
  300. a_i = a[i];
  301. for (var j = 0; j < b_l; ++j) {
  302. b_j = b[j];
  303. product = a_i * b_j + r[i + j];
  304. carry = Math.floor(product / base);
  305. r[i + j] = product - carry * base;
  306. r[i + j + 1] += carry;
  307. }
  308. }
  309. trim(r);
  310. return r;
  311. }
  312. function multiplySmall(a, b) { // assumes a is array, b is number with |b| < BASE
  313. var l = a.length,
  314. r = new Array(l),
  315. base = BASE,
  316. carry = 0,
  317. product, i;
  318. for (i = 0; i < l; i++) {
  319. product = a[i] * b + carry;
  320. carry = Math.floor(product / base);
  321. r[i] = product - carry * base;
  322. }
  323. while (carry > 0) {
  324. r[i++] = carry % base;
  325. carry = Math.floor(carry / base);
  326. }
  327. return r;
  328. }
  329. function shiftLeft(x, n) {
  330. var r = [];
  331. while (n-- > 0) r.push(0);
  332. return r.concat(x);
  333. }
  334. function multiplyKaratsuba(x, y) {
  335. var n = Math.max(x.length, y.length);
  336. if (n <= 30) return multiplyLong(x, y);
  337. n = Math.ceil(n / 2);
  338. var b = x.slice(n),
  339. a = x.slice(0, n),
  340. d = y.slice(n),
  341. c = y.slice(0, n);
  342. var ac = multiplyKaratsuba(a, c),
  343. bd = multiplyKaratsuba(b, d),
  344. abcd = multiplyKaratsuba(addAny(a, b), addAny(c, d));
  345. var product = addAny(addAny(ac, shiftLeft(subtract(subtract(abcd, ac), bd), n)), shiftLeft(bd, 2 * n));
  346. trim(product);
  347. return product;
  348. }
  349. // The following function is derived from a surface fit of a graph plotting the performance difference
  350. // between long multiplication and karatsuba multiplication versus the lengths of the two arrays.
  351. function useKaratsuba(l1, l2) {
  352. return -0.012 * l1 - 0.012 * l2 + 0.000015 * l1 * l2 > 0;
  353. }
  354. BigInteger.prototype.multiply = function (v) {
  355. var n = parseValue(v),
  356. a = this.value, b = n.value,
  357. sign = this.sign !== n.sign,
  358. abs;
  359. if (n.isSmall) {
  360. if (b === 0) return Integer[0];
  361. if (b === 1) return this;
  362. if (b === -1) return this.negate();
  363. abs = Math.abs(b);
  364. if (abs < BASE) {
  365. return new BigInteger(multiplySmall(a, abs), sign);
  366. }
  367. b = smallToArray(abs);
  368. }
  369. if (useKaratsuba(a.length, b.length)) // Karatsuba is only faster for certain array sizes
  370. return new BigInteger(multiplyKaratsuba(a, b), sign);
  371. return new BigInteger(multiplyLong(a, b), sign);
  372. };
  373. BigInteger.prototype.times = BigInteger.prototype.multiply;
  374. function multiplySmallAndArray(a, b, sign) { // a >= 0
  375. if (a < BASE) {
  376. return new BigInteger(multiplySmall(b, a), sign);
  377. }
  378. return new BigInteger(multiplyLong(b, smallToArray(a)), sign);
  379. }
  380. SmallInteger.prototype._multiplyBySmall = function (a) {
  381. if (isPrecise(a.value * this.value)) {
  382. return new SmallInteger(a.value * this.value);
  383. }
  384. return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign);
  385. };
  386. BigInteger.prototype._multiplyBySmall = function (a) {
  387. if (a.value === 0) return Integer[0];
  388. if (a.value === 1) return this;
  389. if (a.value === -1) return this.negate();
  390. return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign);
  391. };
  392. SmallInteger.prototype.multiply = function (v) {
  393. return parseValue(v)._multiplyBySmall(this);
  394. };
  395. SmallInteger.prototype.times = SmallInteger.prototype.multiply;
  396. NativeBigInt.prototype.multiply = function (v) {
  397. return new NativeBigInt(this.value * parseValue(v).value);
  398. }
  399. NativeBigInt.prototype.times = NativeBigInt.prototype.multiply;
  400. function square(a) {
  401. //console.assert(2 * BASE * BASE < MAX_INT);
  402. var l = a.length,
  403. r = createArray(l + l),
  404. base = BASE,
  405. product, carry, i, a_i, a_j;
  406. for (i = 0; i < l; i++) {
  407. a_i = a[i];
  408. carry = 0 - a_i * a_i;
  409. for (var j = i; j < l; j++) {
  410. a_j = a[j];
  411. product = 2 * (a_i * a_j) + r[i + j] + carry;
  412. carry = Math.floor(product / base);
  413. r[i + j] = product - carry * base;
  414. }
  415. r[i + l] = carry;
  416. }
  417. trim(r);
  418. return r;
  419. }
  420. BigInteger.prototype.square = function () {
  421. return new BigInteger(square(this.value), false);
  422. };
  423. SmallInteger.prototype.square = function () {
  424. var value = this.value * this.value;
  425. if (isPrecise(value)) return new SmallInteger(value);
  426. return new BigInteger(square(smallToArray(Math.abs(this.value))), false);
  427. };
  428. NativeBigInt.prototype.square = function (v) {
  429. return new NativeBigInt(this.value * this.value);
  430. }
  431. function divMod1(a, b) { // Left over from previous version. Performs faster than divMod2 on smaller input sizes.
  432. var a_l = a.length,
  433. b_l = b.length,
  434. base = BASE,
  435. result = createArray(b.length),
  436. divisorMostSignificantDigit = b[b_l - 1],
  437. // normalization
  438. lambda = Math.ceil(base / (2 * divisorMostSignificantDigit)),
  439. remainder = multiplySmall(a, lambda),
  440. divisor = multiplySmall(b, lambda),
  441. quotientDigit, shift, carry, borrow, i, l, q;
  442. if (remainder.length <= a_l) remainder.push(0);
  443. divisor.push(0);
  444. divisorMostSignificantDigit = divisor[b_l - 1];
  445. for (shift = a_l - b_l; shift >= 0; shift--) {
  446. quotientDigit = base - 1;
  447. if (remainder[shift + b_l] !== divisorMostSignificantDigit) {
  448. quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit);
  449. }
  450. // quotientDigit <= base - 1
  451. carry = 0;
  452. borrow = 0;
  453. l = divisor.length;
  454. for (i = 0; i < l; i++) {
  455. carry += quotientDigit * divisor[i];
  456. q = Math.floor(carry / base);
  457. borrow += remainder[shift + i] - (carry - q * base);
  458. carry = q;
  459. if (borrow < 0) {
  460. remainder[shift + i] = borrow + base;
  461. borrow = -1;
  462. } else {
  463. remainder[shift + i] = borrow;
  464. borrow = 0;
  465. }
  466. }
  467. while (borrow !== 0) {
  468. quotientDigit -= 1;
  469. carry = 0;
  470. for (i = 0; i < l; i++) {
  471. carry += remainder[shift + i] - base + divisor[i];
  472. if (carry < 0) {
  473. remainder[shift + i] = carry + base;
  474. carry = 0;
  475. } else {
  476. remainder[shift + i] = carry;
  477. carry = 1;
  478. }
  479. }
  480. borrow += carry;
  481. }
  482. result[shift] = quotientDigit;
  483. }
  484. // denormalization
  485. remainder = divModSmall(remainder, lambda)[0];
  486. return [arrayToSmall(result), arrayToSmall(remainder)];
  487. }
  488. function divMod2(a, b) { // Implementation idea shamelessly stolen from Silent Matt's library http://silentmatt.com/biginteger/
  489. // Performs faster than divMod1 on larger input sizes.
  490. var a_l = a.length,
  491. b_l = b.length,
  492. result = [],
  493. part = [],
  494. base = BASE,
  495. guess, xlen, highx, highy, check;
  496. while (a_l) {
  497. part.unshift(a[--a_l]);
  498. trim(part);
  499. if (compareAbs(part, b) < 0) {
  500. result.push(0);
  501. continue;
  502. }
  503. xlen = part.length;
  504. highx = part[xlen - 1] * base + part[xlen - 2];
  505. highy = b[b_l - 1] * base + b[b_l - 2];
  506. if (xlen > b_l) {
  507. highx = (highx + 1) * base;
  508. }
  509. guess = Math.ceil(highx / highy);
  510. do {
  511. check = multiplySmall(b, guess);
  512. if (compareAbs(check, part) <= 0) break;
  513. guess--;
  514. } while (guess);
  515. result.push(guess);
  516. part = subtract(part, check);
  517. }
  518. result.reverse();
  519. return [arrayToSmall(result), arrayToSmall(part)];
  520. }
  521. function divModSmall(value, lambda) {
  522. var length = value.length,
  523. quotient = createArray(length),
  524. base = BASE,
  525. i, q, remainder, divisor;
  526. remainder = 0;
  527. for (i = length - 1; i >= 0; --i) {
  528. divisor = remainder * base + value[i];
  529. q = truncate(divisor / lambda);
  530. remainder = divisor - q * lambda;
  531. quotient[i] = q | 0;
  532. }
  533. return [quotient, remainder | 0];
  534. }
  535. function divModAny(self, v) {
  536. var value, n = parseValue(v);
  537. if (supportsNativeBigInt) {
  538. return [new NativeBigInt(self.value / n.value), new NativeBigInt(self.value % n.value)];
  539. }
  540. var a = self.value, b = n.value;
  541. var quotient;
  542. if (b === 0) throw new Error("Cannot divide by zero");
  543. if (self.isSmall) {
  544. if (n.isSmall) {
  545. return [new SmallInteger(truncate(a / b)), new SmallInteger(a % b)];
  546. }
  547. return [Integer[0], self];
  548. }
  549. if (n.isSmall) {
  550. if (b === 1) return [self, Integer[0]];
  551. if (b == -1) return [self.negate(), Integer[0]];
  552. var abs = Math.abs(b);
  553. if (abs < BASE) {
  554. value = divModSmall(a, abs);
  555. quotient = arrayToSmall(value[0]);
  556. var remainder = value[1];
  557. if (self.sign) remainder = -remainder;
  558. if (typeof quotient === "number") {
  559. if (self.sign !== n.sign) quotient = -quotient;
  560. return [new SmallInteger(quotient), new SmallInteger(remainder)];
  561. }
  562. return [new BigInteger(quotient, self.sign !== n.sign), new SmallInteger(remainder)];
  563. }
  564. b = smallToArray(abs);
  565. }
  566. var comparison = compareAbs(a, b);
  567. if (comparison === -1) return [Integer[0], self];
  568. if (comparison === 0) return [Integer[self.sign === n.sign ? 1 : -1], Integer[0]];
  569. // divMod1 is faster on smaller input sizes
  570. if (a.length + b.length <= 200)
  571. value = divMod1(a, b);
  572. else value = divMod2(a, b);
  573. quotient = value[0];
  574. var qSign = self.sign !== n.sign,
  575. mod = value[1],
  576. mSign = self.sign;
  577. if (typeof quotient === "number") {
  578. if (qSign) quotient = -quotient;
  579. quotient = new SmallInteger(quotient);
  580. } else quotient = new BigInteger(quotient, qSign);
  581. if (typeof mod === "number") {
  582. if (mSign) mod = -mod;
  583. mod = new SmallInteger(mod);
  584. } else mod = new BigInteger(mod, mSign);
  585. return [quotient, mod];
  586. }
  587. BigInteger.prototype.divmod = function (v) {
  588. var result = divModAny(this, v);
  589. return {
  590. quotient: result[0],
  591. remainder: result[1]
  592. };
  593. };
  594. NativeBigInt.prototype.divmod = SmallInteger.prototype.divmod = BigInteger.prototype.divmod;
  595. BigInteger.prototype.divide = function (v) {
  596. return divModAny(this, v)[0];
  597. };
  598. NativeBigInt.prototype.over = NativeBigInt.prototype.divide = function (v) {
  599. return new NativeBigInt(this.value / parseValue(v).value);
  600. };
  601. SmallInteger.prototype.over = SmallInteger.prototype.divide = BigInteger.prototype.over = BigInteger.prototype.divide;
  602. BigInteger.prototype.mod = function (v) {
  603. return divModAny(this, v)[1];
  604. };
  605. NativeBigInt.prototype.mod = NativeBigInt.prototype.remainder = function (v) {
  606. return new NativeBigInt(this.value % parseValue(v).value);
  607. };
  608. SmallInteger.prototype.remainder = SmallInteger.prototype.mod = BigInteger.prototype.remainder = BigInteger.prototype.mod;
  609. BigInteger.prototype.pow = function (v) {
  610. var n = parseValue(v),
  611. a = this.value,
  612. b = n.value,
  613. value, x, y;
  614. if (b === 0) return Integer[1];
  615. if (a === 0) return Integer[0];
  616. if (a === 1) return Integer[1];
  617. if (a === -1) return n.isEven() ? Integer[1] : Integer[-1];
  618. if (n.sign) {
  619. return Integer[0];
  620. }
  621. if (!n.isSmall) throw new Error("The exponent " + n.toString() + " is too large.");
  622. if (this.isSmall) {
  623. if (isPrecise(value = Math.pow(a, b)))
  624. return new SmallInteger(truncate(value));
  625. }
  626. x = this;
  627. y = Integer[1];
  628. while (true) {
  629. if (b & 1 === 1) {
  630. y = y.times(x);
  631. --b;
  632. }
  633. if (b === 0) break;
  634. b /= 2;
  635. x = x.square();
  636. }
  637. return y;
  638. };
  639. SmallInteger.prototype.pow = BigInteger.prototype.pow;
  640. NativeBigInt.prototype.pow = function (v) {
  641. var n = parseValue(v);
  642. var a = this.value, b = n.value;
  643. var _0 = BigInt(0), _1 = BigInt(1), _2 = BigInt(2);
  644. if (b === _0) return Integer[1];
  645. if (a === _0) return Integer[0];
  646. if (a === _1) return Integer[1];
  647. if (a === BigInt(-1)) return n.isEven() ? Integer[1] : Integer[-1];
  648. if (n.isNegative()) return new NativeBigInt(_0);
  649. var x = this;
  650. var y = Integer[1];
  651. while (true) {
  652. if ((b & _1) === _1) {
  653. y = y.times(x);
  654. --b;
  655. }
  656. if (b === _0) break;
  657. b /= _2;
  658. x = x.square();
  659. }
  660. return y;
  661. }
  662. BigInteger.prototype.modPow = function (exp, mod) {
  663. exp = parseValue(exp);
  664. mod = parseValue(mod);
  665. if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0");
  666. var r = Integer[1],
  667. base = this.mod(mod);
  668. while (exp.isPositive()) {
  669. if (base.isZero()) return Integer[0];
  670. if (exp.isOdd()) r = r.multiply(base).mod(mod);
  671. exp = exp.divide(2);
  672. base = base.square().mod(mod);
  673. }
  674. return r;
  675. };
  676. NativeBigInt.prototype.modPow = SmallInteger.prototype.modPow = BigInteger.prototype.modPow;
  677. function compareAbs(a, b) {
  678. if (a.length !== b.length) {
  679. return a.length > b.length ? 1 : -1;
  680. }
  681. for (var i = a.length - 1; i >= 0; i--) {
  682. if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1;
  683. }
  684. return 0;
  685. }
  686. BigInteger.prototype.compareAbs = function (v) {
  687. var n = parseValue(v),
  688. a = this.value,
  689. b = n.value;
  690. if (n.isSmall) return 1;
  691. return compareAbs(a, b);
  692. };
  693. SmallInteger.prototype.compareAbs = function (v) {
  694. var n = parseValue(v),
  695. a = Math.abs(this.value),
  696. b = n.value;
  697. if (n.isSmall) {
  698. b = Math.abs(b);
  699. return a === b ? 0 : a > b ? 1 : -1;
  700. }
  701. return -1;
  702. };
  703. NativeBigInt.prototype.compareAbs = function (v) {
  704. var a = this.value;
  705. var b = parseValue(v).value;
  706. a = a >= 0 ? a : -a;
  707. b = b >= 0 ? b : -b;
  708. return a === b ? 0 : a > b ? 1 : -1;
  709. }
  710. BigInteger.prototype.compare = function (v) {
  711. // See discussion about comparison with Infinity:
  712. // https://github.com/peterolson/BigInteger.js/issues/61
  713. if (v === Infinity) {
  714. return -1;
  715. }
  716. if (v === -Infinity) {
  717. return 1;
  718. }
  719. var n = parseValue(v),
  720. a = this.value,
  721. b = n.value;
  722. if (this.sign !== n.sign) {
  723. return n.sign ? 1 : -1;
  724. }
  725. if (n.isSmall) {
  726. return this.sign ? -1 : 1;
  727. }
  728. return compareAbs(a, b) * (this.sign ? -1 : 1);
  729. };
  730. BigInteger.prototype.compareTo = BigInteger.prototype.compare;
  731. SmallInteger.prototype.compare = function (v) {
  732. if (v === Infinity) {
  733. return -1;
  734. }
  735. if (v === -Infinity) {
  736. return 1;
  737. }
  738. var n = parseValue(v),
  739. a = this.value,
  740. b = n.value;
  741. if (n.isSmall) {
  742. return a == b ? 0 : a > b ? 1 : -1;
  743. }
  744. if (a < 0 !== n.sign) {
  745. return a < 0 ? -1 : 1;
  746. }
  747. return a < 0 ? 1 : -1;
  748. };
  749. SmallInteger.prototype.compareTo = SmallInteger.prototype.compare;
  750. NativeBigInt.prototype.compare = function (v) {
  751. if (v === Infinity) {
  752. return -1;
  753. }
  754. if (v === -Infinity) {
  755. return 1;
  756. }
  757. var a = this.value;
  758. var b = parseValue(v).value;
  759. return a === b ? 0 : a > b ? 1 : -1;
  760. }
  761. NativeBigInt.prototype.compareTo = NativeBigInt.prototype.compare;
  762. BigInteger.prototype.equals = function (v) {
  763. return this.compare(v) === 0;
  764. };
  765. NativeBigInt.prototype.eq = NativeBigInt.prototype.equals = SmallInteger.prototype.eq = SmallInteger.prototype.equals = BigInteger.prototype.eq = BigInteger.prototype.equals;
  766. BigInteger.prototype.notEquals = function (v) {
  767. return this.compare(v) !== 0;
  768. };
  769. NativeBigInt.prototype.neq = NativeBigInt.prototype.notEquals = SmallInteger.prototype.neq = SmallInteger.prototype.notEquals = BigInteger.prototype.neq = BigInteger.prototype.notEquals;
  770. BigInteger.prototype.greater = function (v) {
  771. return this.compare(v) > 0;
  772. };
  773. NativeBigInt.prototype.gt = NativeBigInt.prototype.greater = SmallInteger.prototype.gt = SmallInteger.prototype.greater = BigInteger.prototype.gt = BigInteger.prototype.greater;
  774. BigInteger.prototype.lesser = function (v) {
  775. return this.compare(v) < 0;
  776. };
  777. NativeBigInt.prototype.lt = NativeBigInt.prototype.lesser = SmallInteger.prototype.lt = SmallInteger.prototype.lesser = BigInteger.prototype.lt = BigInteger.prototype.lesser;
  778. BigInteger.prototype.greaterOrEquals = function (v) {
  779. return this.compare(v) >= 0;
  780. };
  781. NativeBigInt.prototype.geq = NativeBigInt.prototype.greaterOrEquals = SmallInteger.prototype.geq = SmallInteger.prototype.greaterOrEquals = BigInteger.prototype.geq = BigInteger.prototype.greaterOrEquals;
  782. BigInteger.prototype.lesserOrEquals = function (v) {
  783. return this.compare(v) <= 0;
  784. };
  785. NativeBigInt.prototype.leq = NativeBigInt.prototype.lesserOrEquals = SmallInteger.prototype.leq = SmallInteger.prototype.lesserOrEquals = BigInteger.prototype.leq = BigInteger.prototype.lesserOrEquals;
  786. BigInteger.prototype.isEven = function () {
  787. return (this.value[0] & 1) === 0;
  788. };
  789. SmallInteger.prototype.isEven = function () {
  790. return (this.value & 1) === 0;
  791. };
  792. NativeBigInt.prototype.isEven = function () {
  793. return (this.value & BigInt(1)) === BigInt(0);
  794. }
  795. BigInteger.prototype.isOdd = function () {
  796. return (this.value[0] & 1) === 1;
  797. };
  798. SmallInteger.prototype.isOdd = function () {
  799. return (this.value & 1) === 1;
  800. };
  801. NativeBigInt.prototype.isOdd = function () {
  802. return (this.value & BigInt(1)) === BigInt(1);
  803. }
  804. BigInteger.prototype.isPositive = function () {
  805. return !this.sign;
  806. };
  807. SmallInteger.prototype.isPositive = function () {
  808. return this.value > 0;
  809. };
  810. NativeBigInt.prototype.isPositive = SmallInteger.prototype.isPositive;
  811. BigInteger.prototype.isNegative = function () {
  812. return this.sign;
  813. };
  814. SmallInteger.prototype.isNegative = function () {
  815. return this.value < 0;
  816. };
  817. NativeBigInt.prototype.isNegative = SmallInteger.prototype.isNegative;
  818. BigInteger.prototype.isUnit = function () {
  819. return false;
  820. };
  821. SmallInteger.prototype.isUnit = function () {
  822. return Math.abs(this.value) === 1;
  823. };
  824. NativeBigInt.prototype.isUnit = function () {
  825. return this.abs().value === BigInt(1);
  826. }
  827. BigInteger.prototype.isZero = function () {
  828. return false;
  829. };
  830. SmallInteger.prototype.isZero = function () {
  831. return this.value === 0;
  832. };
  833. NativeBigInt.prototype.isZero = function () {
  834. return this.value === BigInt(0);
  835. }
  836. BigInteger.prototype.isDivisibleBy = function (v) {
  837. var n = parseValue(v);
  838. if (n.isZero()) return false;
  839. if (n.isUnit()) return true;
  840. if (n.compareAbs(2) === 0) return this.isEven();
  841. return this.mod(n).isZero();
  842. };
  843. NativeBigInt.prototype.isDivisibleBy = SmallInteger.prototype.isDivisibleBy = BigInteger.prototype.isDivisibleBy;
  844. function isBasicPrime(v) {
  845. var n = v.abs();
  846. if (n.isUnit()) return false;
  847. if (n.equals(2) || n.equals(3) || n.equals(5)) return true;
  848. if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false;
  849. if (n.lesser(49)) return true;
  850. // we don't know if it's prime: let the other functions figure it out
  851. }
  852. function millerRabinTest(n, a) {
  853. var nPrev = n.prev(),
  854. b = nPrev,
  855. r = 0,
  856. d, t, i, x;
  857. while (b.isEven()) b = b.divide(2), r++;
  858. next: for (i = 0; i < a.length; i++) {
  859. if (n.lesser(a[i])) continue;
  860. x = bigInt(a[i]).modPow(b, n);
  861. if (x.isUnit() || x.equals(nPrev)) continue;
  862. for (d = r - 1; d != 0; d--) {
  863. x = x.square().mod(n);
  864. if (x.isUnit()) return false;
  865. if (x.equals(nPrev)) continue next;
  866. }
  867. return false;
  868. }
  869. return true;
  870. }
  871. // Set "strict" to true to force GRH-supported lower bound of 2*log(N)^2
  872. BigInteger.prototype.isPrime = function (strict) {
  873. var isPrime = isBasicPrime(this);
  874. if (isPrime !== undefined) return isPrime;
  875. var n = this.abs();
  876. var bits = n.bitLength();
  877. if (bits <= 64)
  878. return millerRabinTest(n, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]);
  879. var logN = Math.log(2) * bits.toJSNumber();
  880. var t = Math.ceil((strict === true) ? (2 * Math.pow(logN, 2)) : logN);
  881. for (var a = [], i = 0; i < t; i++) {
  882. a.push(bigInt(i + 2));
  883. }
  884. return millerRabinTest(n, a);
  885. };
  886. NativeBigInt.prototype.isPrime = SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime;
  887. BigInteger.prototype.isProbablePrime = function (iterations) {
  888. var isPrime = isBasicPrime(this);
  889. if (isPrime !== undefined) return isPrime;
  890. var n = this.abs();
  891. var t = iterations === undefined ? 5 : iterations;
  892. for (var a = [], i = 0; i < t; i++) {
  893. a.push(bigInt.randBetween(2, n.minus(2)));
  894. }
  895. return millerRabinTest(n, a);
  896. };
  897. NativeBigInt.prototype.isProbablePrime = SmallInteger.prototype.isProbablePrime = BigInteger.prototype.isProbablePrime;
  898. BigInteger.prototype.modInv = function (n) {
  899. var t = bigInt.zero, newT = bigInt.one, r = parseValue(n), newR = this.abs(), q, lastT, lastR;
  900. while (!newR.isZero()) {
  901. q = r.divide(newR);
  902. lastT = t;
  903. lastR = r;
  904. t = newT;
  905. r = newR;
  906. newT = lastT.subtract(q.multiply(newT));
  907. newR = lastR.subtract(q.multiply(newR));
  908. }
  909. if (!r.isUnit()) throw new Error(this.toString() + " and " + n.toString() + " are not co-prime");
  910. if (t.compare(0) === -1) {
  911. t = t.add(n);
  912. }
  913. if (this.isNegative()) {
  914. return t.negate();
  915. }
  916. return t;
  917. };
  918. NativeBigInt.prototype.modInv = SmallInteger.prototype.modInv = BigInteger.prototype.modInv;
  919. BigInteger.prototype.next = function () {
  920. var value = this.value;
  921. if (this.sign) {
  922. return subtractSmall(value, 1, this.sign);
  923. }
  924. return new BigInteger(addSmall(value, 1), this.sign);
  925. };
  926. SmallInteger.prototype.next = function () {
  927. var value = this.value;
  928. if (value + 1 < MAX_INT) return new SmallInteger(value + 1);
  929. return new BigInteger(MAX_INT_ARR, false);
  930. };
  931. NativeBigInt.prototype.next = function () {
  932. return new NativeBigInt(this.value + BigInt(1));
  933. }
  934. BigInteger.prototype.prev = function () {
  935. var value = this.value;
  936. if (this.sign) {
  937. return new BigInteger(addSmall(value, 1), true);
  938. }
  939. return subtractSmall(value, 1, this.sign);
  940. };
  941. SmallInteger.prototype.prev = function () {
  942. var value = this.value;
  943. if (value - 1 > -MAX_INT) return new SmallInteger(value - 1);
  944. return new BigInteger(MAX_INT_ARR, true);
  945. };
  946. NativeBigInt.prototype.prev = function () {
  947. return new NativeBigInt(this.value - BigInt(1));
  948. }
  949. var powersOfTwo = [1];
  950. while (2 * powersOfTwo[powersOfTwo.length - 1] <= BASE) powersOfTwo.push(2 * powersOfTwo[powersOfTwo.length - 1]);
  951. var powers2Length = powersOfTwo.length, highestPower2 = powersOfTwo[powers2Length - 1];
  952. function shift_isSmall(n) {
  953. return Math.abs(n) <= BASE;
  954. }
  955. BigInteger.prototype.shiftLeft = function (v) {
  956. var n = parseValue(v).toJSNumber();
  957. if (!shift_isSmall(n)) {
  958. throw new Error(String(n) + " is too large for shifting.");
  959. }
  960. if (n < 0) return this.shiftRight(-n);
  961. var result = this;
  962. if (result.isZero()) return result;
  963. while (n >= powers2Length) {
  964. result = result.multiply(highestPower2);
  965. n -= powers2Length - 1;
  966. }
  967. return result.multiply(powersOfTwo[n]);
  968. };
  969. NativeBigInt.prototype.shiftLeft = SmallInteger.prototype.shiftLeft = BigInteger.prototype.shiftLeft;
  970. BigInteger.prototype.shiftRight = function (v) {
  971. var remQuo;
  972. var n = parseValue(v).toJSNumber();
  973. if (!shift_isSmall(n)) {
  974. throw new Error(String(n) + " is too large for shifting.");
  975. }
  976. if (n < 0) return this.shiftLeft(-n);
  977. var result = this;
  978. while (n >= powers2Length) {
  979. if (result.isZero() || (result.isNegative() && result.isUnit())) return result;
  980. remQuo = divModAny(result, highestPower2);
  981. result = remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
  982. n -= powers2Length - 1;
  983. }
  984. remQuo = divModAny(result, powersOfTwo[n]);
  985. return remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
  986. };
  987. NativeBigInt.prototype.shiftRight = SmallInteger.prototype.shiftRight = BigInteger.prototype.shiftRight;
  988. function bitwise(x, y, fn) {
  989. y = parseValue(y);
  990. var xSign = x.isNegative(), ySign = y.isNegative();
  991. var xRem = xSign ? x.not() : x,
  992. yRem = ySign ? y.not() : y;
  993. var xDigit = 0, yDigit = 0;
  994. var xDivMod = null, yDivMod = null;
  995. var result = [];
  996. while (!xRem.isZero() || !yRem.isZero()) {
  997. xDivMod = divModAny(xRem, highestPower2);
  998. xDigit = xDivMod[1].toJSNumber();
  999. if (xSign) {
  1000. xDigit = highestPower2 - 1 - xDigit; // two's complement for negative numbers
  1001. }
  1002. yDivMod = divModAny(yRem, highestPower2);
  1003. yDigit = yDivMod[1].toJSNumber();
  1004. if (ySign) {
  1005. yDigit = highestPower2 - 1 - yDigit; // two's complement for negative numbers
  1006. }
  1007. xRem = xDivMod[0];
  1008. yRem = yDivMod[0];
  1009. result.push(fn(xDigit, yDigit));
  1010. }
  1011. var sum = fn(xSign ? 1 : 0, ySign ? 1 : 0) !== 0 ? bigInt(-1) : bigInt(0);
  1012. for (var i = result.length - 1; i >= 0; i -= 1) {
  1013. sum = sum.multiply(highestPower2).add(bigInt(result[i]));
  1014. }
  1015. return sum;
  1016. }
  1017. BigInteger.prototype.not = function () {
  1018. return this.negate().prev();
  1019. };
  1020. NativeBigInt.prototype.not = SmallInteger.prototype.not = BigInteger.prototype.not;
  1021. BigInteger.prototype.and = function (n) {
  1022. return bitwise(this, n, function (a, b) { return a & b; });
  1023. };
  1024. NativeBigInt.prototype.and = SmallInteger.prototype.and = BigInteger.prototype.and;
  1025. BigInteger.prototype.or = function (n) {
  1026. return bitwise(this, n, function (a, b) { return a | b; });
  1027. };
  1028. NativeBigInt.prototype.or = SmallInteger.prototype.or = BigInteger.prototype.or;
  1029. BigInteger.prototype.xor = function (n) {
  1030. return bitwise(this, n, function (a, b) { return a ^ b; });
  1031. };
  1032. NativeBigInt.prototype.xor = SmallInteger.prototype.xor = BigInteger.prototype.xor;
  1033. var LOBMASK_I = 1 << 30, LOBMASK_BI = (BASE & -BASE) * (BASE & -BASE) | LOBMASK_I;
  1034. function roughLOB(n) { // get lowestOneBit (rough)
  1035. // SmallInteger: return Min(lowestOneBit(n), 1 << 30)
  1036. // BigInteger: return Min(lowestOneBit(n), 1 << 14) [BASE=1e7]
  1037. var v = n.value,
  1038. x = typeof v === "number" ? v | LOBMASK_I :
  1039. typeof v === "bigint" ? v | BigInt(LOBMASK_I) :
  1040. v[0] + v[1] * BASE | LOBMASK_BI;
  1041. return x & -x;
  1042. }
  1043. function integerLogarithm(value, base) {
  1044. if (base.compareTo(value) <= 0) {
  1045. var tmp = integerLogarithm(value, base.square(base));
  1046. var p = tmp.p;
  1047. var e = tmp.e;
  1048. var t = p.multiply(base);
  1049. return t.compareTo(value) <= 0 ? { p: t, e: e * 2 + 1 } : { p: p, e: e * 2 };
  1050. }
  1051. return { p: bigInt(1), e: 0 };
  1052. }
  1053. BigInteger.prototype.bitLength = function () {
  1054. var n = this;
  1055. if (n.compareTo(bigInt(0)) < 0) {
  1056. n = n.negate().subtract(bigInt(1));
  1057. }
  1058. if (n.compareTo(bigInt(0)) === 0) {
  1059. return bigInt(0);
  1060. }
  1061. return bigInt(integerLogarithm(n, bigInt(2)).e).add(bigInt(1));
  1062. }
  1063. NativeBigInt.prototype.bitLength = SmallInteger.prototype.bitLength = BigInteger.prototype.bitLength;
  1064. function max(a, b) {
  1065. a = parseValue(a);
  1066. b = parseValue(b);
  1067. return a.greater(b) ? a : b;
  1068. }
  1069. function min(a, b) {
  1070. a = parseValue(a);
  1071. b = parseValue(b);
  1072. return a.lesser(b) ? a : b;
  1073. }
  1074. function gcd(a, b) {
  1075. a = parseValue(a).abs();
  1076. b = parseValue(b).abs();
  1077. if (a.equals(b)) return a;
  1078. if (a.isZero()) return b;
  1079. if (b.isZero()) return a;
  1080. var c = Integer[1], d, t;
  1081. while (a.isEven() && b.isEven()) {
  1082. d = min(roughLOB(a), roughLOB(b));
  1083. a = a.divide(d);
  1084. b = b.divide(d);
  1085. c = c.multiply(d);
  1086. }
  1087. while (a.isEven()) {
  1088. a = a.divide(roughLOB(a));
  1089. }
  1090. do {
  1091. while (b.isEven()) {
  1092. b = b.divide(roughLOB(b));
  1093. }
  1094. if (a.greater(b)) {
  1095. t = b; b = a; a = t;
  1096. }
  1097. b = b.subtract(a);
  1098. } while (!b.isZero());
  1099. return c.isUnit() ? a : a.multiply(c);
  1100. }
  1101. function lcm(a, b) {
  1102. a = parseValue(a).abs();
  1103. b = parseValue(b).abs();
  1104. return a.divide(gcd(a, b)).multiply(b);
  1105. }
  1106. function randBetween(a, b) {
  1107. a = parseValue(a);
  1108. b = parseValue(b);
  1109. var low = min(a, b), high = max(a, b);
  1110. var range = high.subtract(low).add(1);
  1111. if (range.isSmall) return low.add(Math.floor(Math.random() * range));
  1112. var digits = toBase(range, BASE).value;
  1113. var result = [], restricted = true;
  1114. for (var i = 0; i < digits.length; i++) {
  1115. var top = restricted ? digits[i] : BASE;
  1116. var digit = truncate(Math.random() * top);
  1117. result.push(digit);
  1118. if (digit < top) restricted = false;
  1119. }
  1120. return low.add(Integer.fromArray(result, BASE, false));
  1121. }
  1122. var parseBase = function (text, base, alphabet, caseSensitive) {
  1123. alphabet = alphabet || DEFAULT_ALPHABET;
  1124. text = String(text);
  1125. if (!caseSensitive) {
  1126. text = text.toLowerCase();
  1127. alphabet = alphabet.toLowerCase();
  1128. }
  1129. var length = text.length;
  1130. var i;
  1131. var absBase = Math.abs(base);
  1132. var alphabetValues = {};
  1133. for (i = 0; i < alphabet.length; i++) {
  1134. alphabetValues[alphabet[i]] = i;
  1135. }
  1136. for (i = 0; i < length; i++) {
  1137. var c = text[i];
  1138. if (c === "-") continue;
  1139. if (c in alphabetValues) {
  1140. if (alphabetValues[c] >= absBase) {
  1141. if (c === "1" && absBase === 1) continue;
  1142. throw new Error(c + " is not a valid digit in base " + base + ".");
  1143. }
  1144. }
  1145. }
  1146. base = parseValue(base);
  1147. var digits = [];
  1148. var isNegative = text[0] === "-";
  1149. for (i = isNegative ? 1 : 0; i < text.length; i++) {
  1150. var c = text[i];
  1151. if (c in alphabetValues) digits.push(parseValue(alphabetValues[c]));
  1152. else if (c === "<") {
  1153. var start = i;
  1154. do { i++; } while (text[i] !== ">" && i < text.length);
  1155. digits.push(parseValue(text.slice(start + 1, i)));
  1156. }
  1157. else throw new Error(c + " is not a valid character");
  1158. }
  1159. return parseBaseFromArray(digits, base, isNegative);
  1160. };
  1161. function parseBaseFromArray(digits, base, isNegative) {
  1162. var val = Integer[0], pow = Integer[1], i;
  1163. for (i = digits.length - 1; i >= 0; i--) {
  1164. val = val.add(digits[i].times(pow));
  1165. pow = pow.times(base);
  1166. }
  1167. return isNegative ? val.negate() : val;
  1168. }
  1169. function stringify(digit, alphabet) {
  1170. alphabet = alphabet || DEFAULT_ALPHABET;
  1171. if (digit < alphabet.length) {
  1172. return alphabet[digit];
  1173. }
  1174. return "<" + digit + ">";
  1175. }
  1176. function toBase(n, base) {
  1177. base = bigInt(base);
  1178. if (base.isZero()) {
  1179. if (n.isZero()) return { value: [0], isNegative: false };
  1180. throw new Error("Cannot convert nonzero numbers to base 0.");
  1181. }
  1182. if (base.equals(-1)) {
  1183. if (n.isZero()) return { value: [0], isNegative: false };
  1184. if (n.isNegative())
  1185. return {
  1186. value: [].concat.apply([], Array.apply(null, Array(-n.toJSNumber()))
  1187. .map(Array.prototype.valueOf, [1, 0])
  1188. ),
  1189. isNegative: false
  1190. };
  1191. var arr = Array.apply(null, Array(n.toJSNumber() - 1))
  1192. .map(Array.prototype.valueOf, [0, 1]);
  1193. arr.unshift([1]);
  1194. return {
  1195. value: [].concat.apply([], arr),
  1196. isNegative: false
  1197. };
  1198. }
  1199. var neg = false;
  1200. if (n.isNegative() && base.isPositive()) {
  1201. neg = true;
  1202. n = n.abs();
  1203. }
  1204. if (base.isUnit()) {
  1205. if (n.isZero()) return { value: [0], isNegative: false };
  1206. return {
  1207. value: Array.apply(null, Array(n.toJSNumber()))
  1208. .map(Number.prototype.valueOf, 1),
  1209. isNegative: neg
  1210. };
  1211. }
  1212. var out = [];
  1213. var left = n, divmod;
  1214. while (left.isNegative() || left.compareAbs(base) >= 0) {
  1215. divmod = left.divmod(base);
  1216. left = divmod.quotient;
  1217. var digit = divmod.remainder;
  1218. if (digit.isNegative()) {
  1219. digit = base.minus(digit).abs();
  1220. left = left.next();
  1221. }
  1222. out.push(digit.toJSNumber());
  1223. }
  1224. out.push(left.toJSNumber());
  1225. return { value: out.reverse(), isNegative: neg };
  1226. }
  1227. function toBaseString(n, base, alphabet) {
  1228. var arr = toBase(n, base);
  1229. return (arr.isNegative ? "-" : "") + arr.value.map(function (x) {
  1230. return stringify(x, alphabet);
  1231. }).join('');
  1232. }
  1233. BigInteger.prototype.toArray = function (radix) {
  1234. return toBase(this, radix);
  1235. };
  1236. SmallInteger.prototype.toArray = function (radix) {
  1237. return toBase(this, radix);
  1238. };
  1239. NativeBigInt.prototype.toArray = function (radix) {
  1240. return toBase(this, radix);
  1241. };
  1242. BigInteger.prototype.toString = function (radix, alphabet) {
  1243. if (radix === undefined) radix = 10;
  1244. if (radix !== 10) return toBaseString(this, radix, alphabet);
  1245. var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit;
  1246. while (--l >= 0) {
  1247. digit = String(v[l]);
  1248. str += zeros.slice(digit.length) + digit;
  1249. }
  1250. var sign = this.sign ? "-" : "";
  1251. return sign + str;
  1252. };
  1253. SmallInteger.prototype.toString = function (radix, alphabet) {
  1254. if (radix === undefined) radix = 10;
  1255. if (radix != 10) return toBaseString(this, radix, alphabet);
  1256. return String(this.value);
  1257. };
  1258. NativeBigInt.prototype.toString = SmallInteger.prototype.toString;
  1259. NativeBigInt.prototype.toJSON = BigInteger.prototype.toJSON = SmallInteger.prototype.toJSON = function () { return this.toString(); }
  1260. BigInteger.prototype.valueOf = function () {
  1261. return parseInt(this.toString(), 10);
  1262. };
  1263. BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf;
  1264. SmallInteger.prototype.valueOf = function () {
  1265. return this.value;
  1266. };
  1267. SmallInteger.prototype.toJSNumber = SmallInteger.prototype.valueOf;
  1268. NativeBigInt.prototype.valueOf = NativeBigInt.prototype.toJSNumber = function () {
  1269. return parseInt(this.toString(), 10);
  1270. }
  1271. function parseStringValue(v) {
  1272. if (isPrecise(+v)) {
  1273. var x = +v;
  1274. if (x === truncate(x))
  1275. return supportsNativeBigInt ? new NativeBigInt(BigInt(x)) : new SmallInteger(x);
  1276. throw new Error("Invalid integer: " + v);
  1277. }
  1278. var sign = v[0] === "-";
  1279. if (sign) v = v.slice(1);
  1280. var split = v.split(/e/i);
  1281. if (split.length > 2) throw new Error("Invalid integer: " + split.join("e"));
  1282. if (split.length === 2) {
  1283. var exp = split[1];
  1284. if (exp[0] === "+") exp = exp.slice(1);
  1285. exp = +exp;
  1286. if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent.");
  1287. var text = split[0];
  1288. var decimalPlace = text.indexOf(".");
  1289. if (decimalPlace >= 0) {
  1290. exp -= text.length - decimalPlace - 1;
  1291. text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1);
  1292. }
  1293. if (exp < 0) throw new Error("Cannot include negative exponent part for integers");
  1294. text += (new Array(exp + 1)).join("0");
  1295. v = text;
  1296. }
  1297. var isValid = /^([0-9][0-9]*)$/.test(v);
  1298. if (!isValid) throw new Error("Invalid integer: " + v);
  1299. if (supportsNativeBigInt) {
  1300. return new NativeBigInt(BigInt(sign ? "-" + v : v));
  1301. }
  1302. var r = [], max = v.length, l = LOG_BASE, min = max - l;
  1303. while (max > 0) {
  1304. r.push(+v.slice(min, max));
  1305. min -= l;
  1306. if (min < 0) min = 0;
  1307. max -= l;
  1308. }
  1309. trim(r);
  1310. return new BigInteger(r, sign);
  1311. }
  1312. function parseNumberValue(v) {
  1313. if (supportsNativeBigInt) {
  1314. return new NativeBigInt(BigInt(v));
  1315. }
  1316. if (isPrecise(v)) {
  1317. if (v !== truncate(v)) throw new Error(v + " is not an integer.");
  1318. return new SmallInteger(v);
  1319. }
  1320. return parseStringValue(v.toString());
  1321. }
  1322. function parseValue(v) {
  1323. if (typeof v === "number") {
  1324. return parseNumberValue(v);
  1325. }
  1326. if (typeof v === "string") {
  1327. return parseStringValue(v);
  1328. }
  1329. if (typeof v === "bigint") {
  1330. return new NativeBigInt(v);
  1331. }
  1332. return v;
  1333. }
  1334. // Pre-define numbers in range [-999,999]
  1335. for (var i = 0; i < 1000; i++) {
  1336. Integer[i] = parseValue(i);
  1337. if (i > 0) Integer[-i] = parseValue(-i);
  1338. }
  1339. // Backwards compatibility
  1340. Integer.one = Integer[1];
  1341. Integer.zero = Integer[0];
  1342. Integer.minusOne = Integer[-1];
  1343. Integer.max = max;
  1344. Integer.min = min;
  1345. Integer.gcd = gcd;
  1346. Integer.lcm = lcm;
  1347. Integer.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger || x instanceof NativeBigInt; };
  1348. Integer.randBetween = randBetween;
  1349. Integer.fromArray = function (digits, base, isNegative) {
  1350. return parseBaseFromArray(digits.map(parseValue), parseValue(base || 10), isNegative);
  1351. };
  1352. return Integer;
  1353. })();
  1354. // Node.js check
  1355. if (typeof module !== "undefined" && module.hasOwnProperty("exports")) {
  1356. module.exports = bigInt;
  1357. }
  1358. //amd check
  1359. if (typeof define === "function" && define.amd) {
  1360. define("big-integer", [], function () {
  1361. return bigInt;
  1362. });
  1363. }
  1364. },{}],4:[function(require,module,exports){
  1365. (function (process){
  1366. /*
  1367. Copyright 2019 0KIMS association.
  1368. This file is part of websnark (Web Assembly zkSnark Prover).
  1369. websnark is a free software: you can redistribute it and/or modify it
  1370. under the terms of the GNU General Public License as published by
  1371. the Free Software Foundation, either version 3 of the License, or
  1372. (at your option) any later version.
  1373. websnark is distributed in the hope that it will be useful, but WITHOUT
  1374. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1375. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  1376. License for more details.
  1377. You should have received a copy of the GNU General Public License
  1378. along with websnark. If not, see <https://www.gnu.org/licenses/>.
  1379. */
  1380. /* globals WebAssembly, Blob, Worker, navigator, Promise, window */
  1381. const bigInt = require("big-integer");
  1382. const groth16_wasm = require("../build/groth16_wasm.js");
  1383. const assert = require("assert");
  1384. const inBrowser = (typeof window !== "undefined");
  1385. let NodeWorker;
  1386. let NodeCrypto;
  1387. if (!inBrowser) {
  1388. NodeWorker = require("worker_threads").Worker;
  1389. NodeCrypto = require("crypto");
  1390. }
  1391. class Deferred {
  1392. constructor() {
  1393. this.promise = new Promise((resolve, reject)=> {
  1394. this.reject = reject;
  1395. this.resolve = resolve;
  1396. });
  1397. }
  1398. }
  1399. /*
  1400. function delay(ms) {
  1401. return new Promise(resolve => setTimeout(resolve, ms));
  1402. }
  1403. */
  1404. function thread(self) {
  1405. let instance;
  1406. let memory;
  1407. let i32;
  1408. async function init(data) {
  1409. const code = new Uint8Array(data.code);
  1410. const wasmModule = await WebAssembly.compile(code);
  1411. memory = new WebAssembly.Memory({initial:data.init});
  1412. i32 = new Uint32Array(memory.buffer);
  1413. instance = await WebAssembly.instantiate(wasmModule, {
  1414. env: {
  1415. "memory": memory
  1416. }
  1417. });
  1418. }
  1419. function alloc(length) {
  1420. while (i32[0] & 3) i32[0]++; // Return always aligned pointers
  1421. const res = i32[0];
  1422. i32[0] += length;
  1423. return res;
  1424. }
  1425. function putBin(b) {
  1426. const p = alloc(b.byteLength);
  1427. const s32 = new Uint32Array(b);
  1428. i32.set(s32, p/4);
  1429. return p;
  1430. }
  1431. function getBin(p, l) {
  1432. return memory.buffer.slice(p, p+l);
  1433. }
  1434. self.onmessage = function(e) {
  1435. let data;
  1436. if (e.data) {
  1437. data = e.data;
  1438. } else {
  1439. data = e;
  1440. }
  1441. if (data.command == "INIT") {
  1442. init(data).then(function() {
  1443. self.postMessage(data.result);
  1444. });
  1445. } else if (data.command == "G1_MULTIEXP") {
  1446. const oldAlloc = i32[0];
  1447. const pScalars = putBin(data.scalars);
  1448. const pPoints = putBin(data.points);
  1449. const pRes = alloc(96);
  1450. instance.exports.g1_zero(pRes);
  1451. instance.exports.g1_multiexp2(pScalars, pPoints, data.n, 7, pRes);
  1452. data.result = getBin(pRes, 96);
  1453. i32[0] = oldAlloc;
  1454. self.postMessage(data.result, [data.result]);
  1455. } else if (data.command == "G2_MULTIEXP") {
  1456. const oldAlloc = i32[0];
  1457. const pScalars = putBin(data.scalars);
  1458. const pPoints = putBin(data.points);
  1459. const pRes = alloc(192);
  1460. instance.exports.g2_zero(pRes);
  1461. instance.exports.g2_multiexp(pScalars, pPoints, data.n, 7, pRes);
  1462. data.result = getBin(pRes, 192);
  1463. i32[0] = oldAlloc;
  1464. self.postMessage(data.result, [data.result]);
  1465. } else if (data.command == "CALC_H") {
  1466. const oldAlloc = i32[0];
  1467. const pSignals = putBin(data.signals);
  1468. const pPolsA = putBin(data.polsA);
  1469. const pPolsB = putBin(data.polsB);
  1470. const nSignals = data.nSignals;
  1471. const domainSize = data.domainSize;
  1472. const pSignalsM = alloc(nSignals*32);
  1473. const pPolA = alloc(domainSize*32);
  1474. const pPolB = alloc(domainSize*32);
  1475. const pPolA2 = alloc(domainSize*32*2);
  1476. const pPolB2 = alloc(domainSize*32*2);
  1477. instance.exports.fft_toMontgomeryN(pSignals, pSignalsM, nSignals);
  1478. instance.exports.pol_zero(pPolA, domainSize);
  1479. instance.exports.pol_zero(pPolB, domainSize);
  1480. instance.exports.pol_constructLC(pPolsA, pSignalsM, nSignals, pPolA);
  1481. instance.exports.pol_constructLC(pPolsB, pSignalsM, nSignals, pPolB);
  1482. instance.exports.fft_copyNInterleaved(pPolA, pPolA2, domainSize);
  1483. instance.exports.fft_copyNInterleaved(pPolB, pPolB2, domainSize);
  1484. instance.exports.fft_ifft(pPolA, domainSize, 0);
  1485. instance.exports.fft_ifft(pPolB, domainSize, 0);
  1486. instance.exports.fft_fft(pPolA, domainSize, 1);
  1487. instance.exports.fft_fft(pPolB, domainSize, 1);
  1488. instance.exports.fft_copyNInterleaved(pPolA, pPolA2+32, domainSize);
  1489. instance.exports.fft_copyNInterleaved(pPolB, pPolB2+32, domainSize);
  1490. instance.exports.fft_mulN(pPolA2, pPolB2, domainSize*2, pPolA2);
  1491. instance.exports.fft_ifft(pPolA2, domainSize*2, 0);
  1492. instance.exports.fft_fromMontgomeryN(pPolA2+domainSize*32, pPolA2+domainSize*32, domainSize);
  1493. data.result = getBin(pPolA2+domainSize*32, domainSize*32);
  1494. i32[0] = oldAlloc;
  1495. self.postMessage(data.result, [data.result]);
  1496. } else if (data.command == "TERMINATE") {
  1497. process.exit();
  1498. }
  1499. };
  1500. }
  1501. async function build() {
  1502. const groth16 = new Groth16();
  1503. groth16.q = bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583");
  1504. groth16.r = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
  1505. groth16.n64 = Math.floor((groth16.q.minus(1).bitLength() - 1)/64) +1;
  1506. groth16.n32 = groth16.n64*2;
  1507. groth16.n8 = groth16.n64*8;
  1508. groth16.memory = new WebAssembly.Memory({initial:1000});
  1509. groth16.i32 = new Uint32Array(groth16.memory.buffer);
  1510. const wasmModule = await WebAssembly.compile(groth16_wasm.code);
  1511. groth16.instance = await WebAssembly.instantiate(wasmModule, {
  1512. env: {
  1513. "memory": groth16.memory
  1514. }
  1515. });
  1516. groth16.pq = groth16_wasm.pq;
  1517. groth16.pr = groth16_wasm.pr;
  1518. groth16.pr0 = groth16.alloc(192);
  1519. groth16.pr1 = groth16.alloc(192);
  1520. groth16.workers = [];
  1521. groth16.pendingDeferreds = [];
  1522. groth16.working = [];
  1523. let concurrency;
  1524. if ((typeof(navigator) === "object") && navigator.hardwareConcurrency) {
  1525. concurrency = navigator.hardwareConcurrency;
  1526. } else {
  1527. concurrency = 8;
  1528. }
  1529. function getOnMsg(i) {
  1530. return function(e) {
  1531. let data;
  1532. if ((e)&&(e.data)) {
  1533. data = e.data;
  1534. } else {
  1535. data = e;
  1536. }
  1537. groth16.working[i]=false;
  1538. groth16.pendingDeferreds[i].resolve(data);
  1539. groth16.processWorks();
  1540. };
  1541. }
  1542. for (let i = 0; i<concurrency; i++) {
  1543. if (inBrowser) {
  1544. const blob = new Blob(["(", thread.toString(), ")(self);"], { type: "text/javascript" });
  1545. const url = URL.createObjectURL(blob);
  1546. groth16.workers[i] = new Worker(url);
  1547. groth16.workers[i].onmessage = getOnMsg(i);
  1548. } else {
  1549. groth16.workers[i] = new NodeWorker("(" + thread.toString()+ ")(require('worker_threads').parentPort);", {eval: true});
  1550. groth16.workers[i].on("message", getOnMsg(i));
  1551. }
  1552. groth16.working[i]=false;
  1553. }
  1554. const initPromises = [];
  1555. for (let i=0; i<groth16.workers.length;i++) {
  1556. const copyCode = groth16_wasm.code.buffer.slice(0);
  1557. initPromises.push(groth16.postAction(i, {
  1558. command: "INIT",
  1559. init: 1000,
  1560. code: copyCode
  1561. }, [copyCode]));
  1562. }
  1563. await Promise.all(initPromises);
  1564. return groth16;
  1565. }
  1566. class Groth16 {
  1567. constructor() {
  1568. this.actionQueue = [];
  1569. }
  1570. postAction(workerId, e, transfers, _deferred) {
  1571. assert(this.working[workerId] == false);
  1572. this.working[workerId] = true;
  1573. this.pendingDeferreds[workerId] = _deferred ? _deferred : new Deferred();
  1574. this.workers[workerId].postMessage(e, transfers);
  1575. return this.pendingDeferreds[workerId].promise;
  1576. }
  1577. processWorks() {
  1578. for (let i=0; (i<this.workers.length)&&(this.actionQueue.length > 0); i++) {
  1579. if (this.working[i] == false) {
  1580. const work = this.actionQueue.shift();
  1581. this.postAction(i, work.data, work.transfers, work.deferred);
  1582. }
  1583. }
  1584. }
  1585. queueAction(actionData, transfers) {
  1586. const d = new Deferred();
  1587. this.actionQueue.push({
  1588. data: actionData,
  1589. transfers: transfers,
  1590. deferred: d
  1591. });
  1592. this.processWorks();
  1593. return d.promise;
  1594. }
  1595. alloc(length) {
  1596. while (this.i32[0] & 3) this.i32[0]++; // Return always aligned pointers
  1597. const res = this.i32[0];
  1598. this.i32[0] += length;
  1599. return res;
  1600. }
  1601. putBin(p, b) {
  1602. const s32 = new Uint32Array(b);
  1603. this.i32.set(s32, p/4);
  1604. }
  1605. getBin(p, l) {
  1606. return this.memory.buffer.slice(p, p+l);
  1607. }
  1608. bin2int(b) {
  1609. const i32 = new Uint32Array(b);
  1610. let acc = bigInt(i32[7]);
  1611. for (let i=6; i>=0; i--) {
  1612. acc = acc.shiftLeft(32);
  1613. acc = acc.add(i32[i]);
  1614. }
  1615. return acc.toString();
  1616. }
  1617. bin2g1(b) {
  1618. return [
  1619. this.bin2int(b.slice(0,32)),
  1620. this.bin2int(b.slice(32,64)),
  1621. this.bin2int(b.slice(64,96)),
  1622. ];
  1623. }
  1624. bin2g2(b) {
  1625. return [
  1626. [
  1627. this.bin2int(b.slice(0,32)),
  1628. this.bin2int(b.slice(32,64))
  1629. ],
  1630. [
  1631. this.bin2int(b.slice(64,96)),
  1632. this.bin2int(b.slice(96,128))
  1633. ],
  1634. [
  1635. this.bin2int(b.slice(128,160)),
  1636. this.bin2int(b.slice(160,192))
  1637. ],
  1638. ];
  1639. }
  1640. async g1_multiexp(scalars, points) {
  1641. const nPoints = scalars.byteLength /32;
  1642. const nPointsPerThread = Math.floor(nPoints / this.workers.length);
  1643. const opPromises = [];
  1644. for (let i=0; i<this.workers.length; i++) {
  1645. const th_nPoints =
  1646. i < this.workers.length -1 ?
  1647. nPointsPerThread :
  1648. nPoints - (nPointsPerThread * (this.workers.length -1));
  1649. const scalars_th = scalars.slice(i*nPointsPerThread*32, i*nPointsPerThread*32 + th_nPoints*32);
  1650. const points_th = points.slice(i*nPointsPerThread*64, i*nPointsPerThread*64 + th_nPoints*64);
  1651. opPromises.push(
  1652. this.queueAction({
  1653. command: "G1_MULTIEXP",
  1654. scalars: scalars_th,
  1655. points: points_th,
  1656. n: th_nPoints
  1657. }, [scalars_th, points_th])
  1658. );
  1659. }
  1660. const results = await Promise.all(opPromises);
  1661. this.instance.exports.g1_zero(this.pr0);
  1662. for (let i=0; i<results.length; i++) {
  1663. this.putBin(this.pr1, results[i]);
  1664. this.instance.exports.g1_add(this.pr0, this.pr1, this.pr0);
  1665. }
  1666. return this.getBin(this.pr0, 96);
  1667. }
  1668. async g2_multiexp(scalars, points) {
  1669. const nPoints = scalars.byteLength /32;
  1670. const nPointsPerThread = Math.floor(nPoints / this.workers.length);
  1671. const opPromises = [];
  1672. for (let i=0; i<this.workers.length; i++) {
  1673. const th_nPoints =
  1674. i < this.workers.length -1 ?
  1675. nPointsPerThread :
  1676. nPoints - (nPointsPerThread * (this.workers.length -1));
  1677. const scalars_th = scalars.slice(i*nPointsPerThread*32, i*nPointsPerThread*32 + th_nPoints*32);
  1678. const points_th = points.slice(i*nPointsPerThread*128, i*nPointsPerThread*128 + th_nPoints*128);
  1679. opPromises.push(
  1680. this.queueAction({
  1681. command: "G2_MULTIEXP",
  1682. scalars: scalars_th,
  1683. points: points_th,
  1684. n: th_nPoints
  1685. }, [scalars_th, points_th])
  1686. );
  1687. }
  1688. const results = await Promise.all(opPromises);
  1689. this.instance.exports.g2_zero(this.pr0);
  1690. for (let i=0; i<results.length; i++) {
  1691. this.putBin(this.pr1, results[i]);
  1692. this.instance.exports.g2_add(this.pr0, this.pr1, this.pr0);
  1693. }
  1694. return this.getBin(this.pr0, 192);
  1695. }
  1696. g1_affine(p) {
  1697. this.putBin(this.pr0, p);
  1698. this.instance.exports.g1_affine(this.pr0, this.pr0);
  1699. return this.getBin(this.pr0, 96);
  1700. }
  1701. g2_affine(p) {
  1702. this.putBin(this.pr0, p);
  1703. this.instance.exports.g2_affine(this.pr0, this.pr0);
  1704. return this.getBin(this.pr0, 192);
  1705. }
  1706. g1_fromMontgomery(p) {
  1707. this.putBin(this.pr0, p);
  1708. this.instance.exports.g1_fromMontgomery(this.pr0, this.pr0);
  1709. return this.getBin(this.pr0, 96);
  1710. }
  1711. g2_fromMontgomery(p) {
  1712. this.putBin(this.pr0, p);
  1713. this.instance.exports.g2_fromMontgomery(this.pr0, this.pr0);
  1714. return this.getBin(this.pr0, 192);
  1715. }
  1716. loadPoint1(b) {
  1717. const p = this.alloc(96);
  1718. this.putBin(p, b);
  1719. this.instance.exports.f1m_one(p+64);
  1720. return p;
  1721. }
  1722. loadPoint2(b) {
  1723. const p = this.alloc(192);
  1724. this.putBin(p, b);
  1725. this.instance.exports.f2m_one(p+128);
  1726. return p;
  1727. }
  1728. terminate() {
  1729. for (let i=0; i<this.workers.length; i++) {
  1730. this.workers[i].postMessage({command: "TERMINATE"});
  1731. }
  1732. }
  1733. async calcH(signals, polsA, polsB, nSignals, domainSize) {
  1734. return this.queueAction({
  1735. command: "CALC_H",
  1736. signals: signals,
  1737. polsA: polsA,
  1738. polsB: polsB,
  1739. nSignals: nSignals,
  1740. domainSize: domainSize
  1741. }, [signals, polsA, polsB]);
  1742. }
  1743. async proof(signals, pkey) {
  1744. const pkey32 = new Uint32Array(pkey);
  1745. const nSignals = pkey32[0];
  1746. const nPublic = pkey32[1];
  1747. const domainSize = pkey32[2];
  1748. const pPolsA = pkey32[3];
  1749. const pPolsB = pkey32[4];
  1750. const pPointsA = pkey32[5];
  1751. const pPointsB1 = pkey32[6];
  1752. const pPointsB2 = pkey32[7];
  1753. const pPointsC = pkey32[8];
  1754. const pHExps = pkey32[9];
  1755. const polsA = pkey.slice(pPolsA, pPolsA + pPolsB);
  1756. const polsB = pkey.slice(pPolsB, pPolsB + pPointsA);
  1757. const pointsA = pkey.slice(pPointsA, pPointsA + nSignals*64);
  1758. const pointsB1 = pkey.slice(pPointsB1, pPointsB1 + nSignals*64);
  1759. const pointsB2 = pkey.slice(pPointsB2, pPointsB2 + nSignals*128);
  1760. const pointsC = pkey.slice(pPointsC, pPointsC + (nSignals-nPublic-1)*64);
  1761. const pointsHExps = pkey.slice(pHExps, pHExps + domainSize*64);
  1762. const alfa1 = pkey.slice(10*4, 10*4 + 64);
  1763. const beta1 = pkey.slice(10*4 + 64, 10*4 + 128);
  1764. const delta1 = pkey.slice(10*4 + 128, 10*4 + 192);
  1765. const beta2 = pkey.slice(10*4 + 192, 10*4 + 320);
  1766. const delta2 = pkey.slice(10*4 + 320, 10*4 + 448);
  1767. const pH = this.calcH(signals.slice(0), polsA, polsB, nSignals, domainSize).then( (h) => {
  1768. /* Debug code to print the result of h
  1769. for (let i=0; i<domainSize; i++) {
  1770. const a = this.bin2int(h.slice(i*32, i*32+32));
  1771. console.log(i + " -> " + a.toString());
  1772. }
  1773. */
  1774. return this.g1_multiexp(h, pointsHExps);
  1775. });
  1776. const pA = this.g1_multiexp(signals.slice(0), pointsA);
  1777. const pB1 = this.g1_multiexp(signals.slice(0), pointsB1);
  1778. const pB2 = this.g2_multiexp(signals.slice(0), pointsB2);
  1779. const pC = this.g1_multiexp(signals.slice((nPublic+1)*32), pointsC);
  1780. const res = await Promise.all([pA, pB1, pB2, pC, pH]);
  1781. const pi_a = this.alloc(96);
  1782. const pi_b = this.alloc(192);
  1783. const pi_c = this.alloc(96);
  1784. const pib1 = this.alloc(96);
  1785. this.putBin(pi_a, res[0]);
  1786. this.putBin(pib1, res[1]);
  1787. this.putBin(pi_b, res[2]);
  1788. this.putBin(pi_c, res[3]);
  1789. const pAlfa1 = this.loadPoint1(alfa1);
  1790. const pBeta1 = this.loadPoint1(beta1);
  1791. const pDelta1 = this.loadPoint1(delta1);
  1792. const pBeta2 = this.loadPoint2(beta2);
  1793. const pDelta2 = this.loadPoint2(delta2);
  1794. let rnd = new Uint32Array(8);
  1795. const aux1 = this.alloc(96);
  1796. const aux2 = this.alloc(192);
  1797. const pr = this.alloc(32);
  1798. const ps = this.alloc(32);
  1799. if (inBrowser) {
  1800. window.crypto.getRandomValues(rnd);
  1801. this.putBin(pr, rnd);
  1802. window.crypto.getRandomValues(rnd);
  1803. this.putBin(ps, rnd);
  1804. } else {
  1805. const br = NodeCrypto.randomBytes(32);
  1806. this.putBin(pr, br);
  1807. const bs = NodeCrypto.randomBytes(32);
  1808. this.putBin(ps, bs);
  1809. }
  1810. /// Uncoment it to debug and check it works
  1811. // this.instance.exports.f1m_zero(pr);
  1812. // this.instance.exports.f1m_zero(ps);
  1813. // pi_a = pi_a + Alfa1 + r*Delta1
  1814. this.instance.exports.g1_add(pAlfa1, pi_a, pi_a);
  1815. this.instance.exports.g1_timesScalar(pDelta1, pr, 32, aux1);
  1816. this.instance.exports.g1_add(aux1, pi_a, pi_a);
  1817. // pi_b = pi_b + Beta2 + s*Delta2
  1818. this.instance.exports.g2_add(pBeta2, pi_b, pi_b);
  1819. this.instance.exports.g2_timesScalar(pDelta2, ps, 32, aux2);
  1820. this.instance.exports.g2_add(aux2, pi_b, pi_b);
  1821. // pib1 = pib1 + Beta1 + s*Delta1
  1822. this.instance.exports.g1_add(pBeta1, pib1, pib1);
  1823. this.instance.exports.g1_timesScalar(pDelta1, ps, 32, aux1);
  1824. this.instance.exports.g1_add(aux1, pib1, pib1);
  1825. // pi_c = pi_c + pH
  1826. this.putBin(aux1, res[4]);
  1827. this.instance.exports.g1_add(aux1, pi_c, pi_c);
  1828. // pi_c = pi_c + s*pi_a
  1829. this.instance.exports.g1_timesScalar(pi_a, ps, 32, aux1);
  1830. this.instance.exports.g1_add(aux1, pi_c, pi_c);
  1831. // pi_c = pi_c + r*pib1
  1832. this.instance.exports.g1_timesScalar(pib1, pr, 32, aux1);
  1833. this.instance.exports.g1_add(aux1, pi_c, pi_c);
  1834. // pi_c = pi_c - r*s*delta1
  1835. const prs = this.alloc(64);
  1836. this.instance.exports.int_mul(pr, ps, prs);
  1837. this.instance.exports.g1_timesScalar(pDelta1, prs, 64, aux1);
  1838. this.instance.exports.g1_neg(aux1, aux1);
  1839. this.instance.exports.g1_add(aux1, pi_c, pi_c);
  1840. this.instance.exports.g1_affine(pi_a, pi_a);
  1841. this.instance.exports.g2_affine(pi_b, pi_b);
  1842. this.instance.exports.g1_affine(pi_c, pi_c);
  1843. this.instance.exports.g1_fromMontgomery(pi_a, pi_a);
  1844. this.instance.exports.g2_fromMontgomery(pi_b, pi_b);
  1845. this.instance.exports.g1_fromMontgomery(pi_c, pi_c);
  1846. return {
  1847. pi_a: this.bin2g1(this.getBin(pi_a, 96)),
  1848. pi_b: this.bin2g2(this.getBin(pi_b, 192)),
  1849. pi_c: this.bin2g1(this.getBin(pi_c, 96)),
  1850. };
  1851. }
  1852. }
  1853. module.exports = build;
  1854. }).call(this,require('_process'))
  1855. },{"../build/groth16_wasm.js":1,"_process":12,"assert":5,"big-integer":3,"crypto":undefined,"worker_threads":undefined}],5:[function(require,module,exports){
  1856. (function (global){
  1857. 'use strict';
  1858. // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
  1859. // original notice:
  1860. /*!
  1861. * The buffer module from node.js, for the browser.
  1862. *
  1863. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  1864. * @license MIT
  1865. */
  1866. function compare(a, b) {
  1867. if (a === b) {
  1868. return 0;
  1869. }
  1870. var x = a.length;
  1871. var y = b.length;
  1872. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  1873. if (a[i] !== b[i]) {
  1874. x = a[i];
  1875. y = b[i];
  1876. break;
  1877. }
  1878. }
  1879. if (x < y) {
  1880. return -1;
  1881. }
  1882. if (y < x) {
  1883. return 1;
  1884. }
  1885. return 0;
  1886. }
  1887. function isBuffer(b) {
  1888. if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
  1889. return global.Buffer.isBuffer(b);
  1890. }
  1891. return !!(b != null && b._isBuffer);
  1892. }
  1893. // based on node assert, original notice:
  1894. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  1895. //
  1896. // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  1897. //
  1898. // Originally from narwhal.js (http://narwhaljs.org)
  1899. // Copyright (c) 2009 Thomas Robinson <280north.com>
  1900. //
  1901. // Permission is hereby granted, free of charge, to any person obtaining a copy
  1902. // of this software and associated documentation files (the 'Software'), to
  1903. // deal in the Software without restriction, including without limitation the
  1904. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  1905. // sell copies of the Software, and to permit persons to whom the Software is
  1906. // furnished to do so, subject to the following conditions:
  1907. //
  1908. // The above copyright notice and this permission notice shall be included in
  1909. // all copies or substantial portions of the Software.
  1910. //
  1911. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1912. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1913. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1914. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  1915. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  1916. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  1917. var util = require('util/');
  1918. var hasOwn = Object.prototype.hasOwnProperty;
  1919. var pSlice = Array.prototype.slice;
  1920. var functionsHaveNames = (function () {
  1921. return function foo() {}.name === 'foo';
  1922. }());
  1923. function pToString (obj) {
  1924. return Object.prototype.toString.call(obj);
  1925. }
  1926. function isView(arrbuf) {
  1927. if (isBuffer(arrbuf)) {
  1928. return false;
  1929. }
  1930. if (typeof global.ArrayBuffer !== 'function') {
  1931. return false;
  1932. }
  1933. if (typeof ArrayBuffer.isView === 'function') {
  1934. return ArrayBuffer.isView(arrbuf);
  1935. }
  1936. if (!arrbuf) {
  1937. return false;
  1938. }
  1939. if (arrbuf instanceof DataView) {
  1940. return true;
  1941. }
  1942. if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
  1943. return true;
  1944. }
  1945. return false;
  1946. }
  1947. // 1. The assert module provides functions that throw
  1948. // AssertionError's when particular conditions are not met. The
  1949. // assert module must conform to the following interface.
  1950. var assert = module.exports = ok;
  1951. // 2. The AssertionError is defined in assert.
  1952. // new assert.AssertionError({ message: message,
  1953. // actual: actual,
  1954. // expected: expected })
  1955. var regex = /\s*function\s+([^\(\s]*)\s*/;
  1956. // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
  1957. function getName(func) {
  1958. if (!util.isFunction(func)) {
  1959. return;
  1960. }
  1961. if (functionsHaveNames) {
  1962. return func.name;
  1963. }
  1964. var str = func.toString();
  1965. var match = str.match(regex);
  1966. return match && match[1];
  1967. }
  1968. assert.AssertionError = function AssertionError(options) {
  1969. this.name = 'AssertionError';
  1970. this.actual = options.actual;
  1971. this.expected = options.expected;
  1972. this.operator = options.operator;
  1973. if (options.message) {
  1974. this.message = options.message;
  1975. this.generatedMessage = false;
  1976. } else {
  1977. this.message = getMessage(this);
  1978. this.generatedMessage = true;
  1979. }
  1980. var stackStartFunction = options.stackStartFunction || fail;
  1981. if (Error.captureStackTrace) {
  1982. Error.captureStackTrace(this, stackStartFunction);
  1983. } else {
  1984. // non v8 browsers so we can have a stacktrace
  1985. var err = new Error();
  1986. if (err.stack) {
  1987. var out = err.stack;
  1988. // try to strip useless frames
  1989. var fn_name = getName(stackStartFunction);
  1990. var idx = out.indexOf('\n' + fn_name);
  1991. if (idx >= 0) {
  1992. // once we have located the function frame
  1993. // we need to strip out everything before it (and its line)
  1994. var next_line = out.indexOf('\n', idx + 1);
  1995. out = out.substring(next_line + 1);
  1996. }
  1997. this.stack = out;
  1998. }
  1999. }
  2000. };
  2001. // assert.AssertionError instanceof Error
  2002. util.inherits(assert.AssertionError, Error);
  2003. function truncate(s, n) {
  2004. if (typeof s === 'string') {
  2005. return s.length < n ? s : s.slice(0, n);
  2006. } else {
  2007. return s;
  2008. }
  2009. }
  2010. function inspect(something) {
  2011. if (functionsHaveNames || !util.isFunction(something)) {
  2012. return util.inspect(something);
  2013. }
  2014. var rawname = getName(something);
  2015. var name = rawname ? ': ' + rawname : '';
  2016. return '[Function' + name + ']';
  2017. }
  2018. function getMessage(self) {
  2019. return truncate(inspect(self.actual), 128) + ' ' +
  2020. self.operator + ' ' +
  2021. truncate(inspect(self.expected), 128);
  2022. }
  2023. // At present only the three keys mentioned above are used and
  2024. // understood by the spec. Implementations or sub modules can pass
  2025. // other keys to the AssertionError's constructor - they will be
  2026. // ignored.
  2027. // 3. All of the following functions must throw an AssertionError
  2028. // when a corresponding condition is not met, with a message that
  2029. // may be undefined if not provided. All assertion methods provide
  2030. // both the actual and expected values to the assertion error for
  2031. // display purposes.
  2032. function fail(actual, expected, message, operator, stackStartFunction) {
  2033. throw new assert.AssertionError({
  2034. message: message,
  2035. actual: actual,
  2036. expected: expected,
  2037. operator: operator,
  2038. stackStartFunction: stackStartFunction
  2039. });
  2040. }
  2041. // EXTENSION! allows for well behaved errors defined elsewhere.
  2042. assert.fail = fail;
  2043. // 4. Pure assertion tests whether a value is truthy, as determined
  2044. // by !!guard.
  2045. // assert.ok(guard, message_opt);
  2046. // This statement is equivalent to assert.equal(true, !!guard,
  2047. // message_opt);. To test strictly for the value true, use
  2048. // assert.strictEqual(true, guard, message_opt);.
  2049. function ok(value, message) {
  2050. if (!value) fail(value, true, message, '==', assert.ok);
  2051. }
  2052. assert.ok = ok;
  2053. // 5. The equality assertion tests shallow, coercive equality with
  2054. // ==.
  2055. // assert.equal(actual, expected, message_opt);
  2056. assert.equal = function equal(actual, expected, message) {
  2057. if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  2058. };
  2059. // 6. The non-equality assertion tests for whether two objects are not equal
  2060. // with != assert.notEqual(actual, expected, message_opt);
  2061. assert.notEqual = function notEqual(actual, expected, message) {
  2062. if (actual == expected) {
  2063. fail(actual, expected, message, '!=', assert.notEqual);
  2064. }
  2065. };
  2066. // 7. The equivalence assertion tests a deep equality relation.
  2067. // assert.deepEqual(actual, expected, message_opt);
  2068. assert.deepEqual = function deepEqual(actual, expected, message) {
  2069. if (!_deepEqual(actual, expected, false)) {
  2070. fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  2071. }
  2072. };
  2073. assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
  2074. if (!_deepEqual(actual, expected, true)) {
  2075. fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
  2076. }
  2077. };
  2078. function _deepEqual(actual, expected, strict, memos) {
  2079. // 7.1. All identical values are equivalent, as determined by ===.
  2080. if (actual === expected) {
  2081. return true;
  2082. } else if (isBuffer(actual) && isBuffer(expected)) {
  2083. return compare(actual, expected) === 0;
  2084. // 7.2. If the expected value is a Date object, the actual value is
  2085. // equivalent if it is also a Date object that refers to the same time.
  2086. } else if (util.isDate(actual) && util.isDate(expected)) {
  2087. return actual.getTime() === expected.getTime();
  2088. // 7.3 If the expected value is a RegExp object, the actual value is
  2089. // equivalent if it is also a RegExp object with the same source and
  2090. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  2091. } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  2092. return actual.source === expected.source &&
  2093. actual.global === expected.global &&
  2094. actual.multiline === expected.multiline &&
  2095. actual.lastIndex === expected.lastIndex &&
  2096. actual.ignoreCase === expected.ignoreCase;
  2097. // 7.4. Other pairs that do not both pass typeof value == 'object',
  2098. // equivalence is determined by ==.
  2099. } else if ((actual === null || typeof actual !== 'object') &&
  2100. (expected === null || typeof expected !== 'object')) {
  2101. return strict ? actual === expected : actual == expected;
  2102. // If both values are instances of typed arrays, wrap their underlying
  2103. // ArrayBuffers in a Buffer each to increase performance
  2104. // This optimization requires the arrays to have the same type as checked by
  2105. // Object.prototype.toString (aka pToString). Never perform binary
  2106. // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
  2107. // bit patterns are not identical.
  2108. } else if (isView(actual) && isView(expected) &&
  2109. pToString(actual) === pToString(expected) &&
  2110. !(actual instanceof Float32Array ||
  2111. actual instanceof Float64Array)) {
  2112. return compare(new Uint8Array(actual.buffer),
  2113. new Uint8Array(expected.buffer)) === 0;
  2114. // 7.5 For all other Object pairs, including Array objects, equivalence is
  2115. // determined by having the same number of owned properties (as verified
  2116. // with Object.prototype.hasOwnProperty.call), the same set of keys
  2117. // (although not necessarily the same order), equivalent values for every
  2118. // corresponding key, and an identical 'prototype' property. Note: this
  2119. // accounts for both named and indexed properties on Arrays.
  2120. } else if (isBuffer(actual) !== isBuffer(expected)) {
  2121. return false;
  2122. } else {
  2123. memos = memos || {actual: [], expected: []};
  2124. var actualIndex = memos.actual.indexOf(actual);
  2125. if (actualIndex !== -1) {
  2126. if (actualIndex === memos.expected.indexOf(expected)) {
  2127. return true;
  2128. }
  2129. }
  2130. memos.actual.push(actual);
  2131. memos.expected.push(expected);
  2132. return objEquiv(actual, expected, strict, memos);
  2133. }
  2134. }
  2135. function isArguments(object) {
  2136. return Object.prototype.toString.call(object) == '[object Arguments]';
  2137. }
  2138. function objEquiv(a, b, strict, actualVisitedObjects) {
  2139. if (a === null || a === undefined || b === null || b === undefined)
  2140. return false;
  2141. // if one is a primitive, the other must be same
  2142. if (util.isPrimitive(a) || util.isPrimitive(b))
  2143. return a === b;
  2144. if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
  2145. return false;
  2146. var aIsArgs = isArguments(a);
  2147. var bIsArgs = isArguments(b);
  2148. if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
  2149. return false;
  2150. if (aIsArgs) {
  2151. a = pSlice.call(a);
  2152. b = pSlice.call(b);
  2153. return _deepEqual(a, b, strict);
  2154. }
  2155. var ka = objectKeys(a);
  2156. var kb = objectKeys(b);
  2157. var key, i;
  2158. // having the same number of owned properties (keys incorporates
  2159. // hasOwnProperty)
  2160. if (ka.length !== kb.length)
  2161. return false;
  2162. //the same set of keys (although not necessarily the same order),
  2163. ka.sort();
  2164. kb.sort();
  2165. //~~~cheap key test
  2166. for (i = ka.length - 1; i >= 0; i--) {
  2167. if (ka[i] !== kb[i])
  2168. return false;
  2169. }
  2170. //equivalent values for every corresponding key, and
  2171. //~~~possibly expensive deep test
  2172. for (i = ka.length - 1; i >= 0; i--) {
  2173. key = ka[i];
  2174. if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
  2175. return false;
  2176. }
  2177. return true;
  2178. }
  2179. // 8. The non-equivalence assertion tests for any deep inequality.
  2180. // assert.notDeepEqual(actual, expected, message_opt);
  2181. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  2182. if (_deepEqual(actual, expected, false)) {
  2183. fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  2184. }
  2185. };
  2186. assert.notDeepStrictEqual = notDeepStrictEqual;
  2187. function notDeepStrictEqual(actual, expected, message) {
  2188. if (_deepEqual(actual, expected, true)) {
  2189. fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
  2190. }
  2191. }
  2192. // 9. The strict equality assertion tests strict equality, as determined by ===.
  2193. // assert.strictEqual(actual, expected, message_opt);
  2194. assert.strictEqual = function strictEqual(actual, expected, message) {
  2195. if (actual !== expected) {
  2196. fail(actual, expected, message, '===', assert.strictEqual);
  2197. }
  2198. };
  2199. // 10. The strict non-equality assertion tests for strict inequality, as
  2200. // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  2201. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  2202. if (actual === expected) {
  2203. fail(actual, expected, message, '!==', assert.notStrictEqual);
  2204. }
  2205. };
  2206. function expectedException(actual, expected) {
  2207. if (!actual || !expected) {
  2208. return false;
  2209. }
  2210. if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  2211. return expected.test(actual);
  2212. }
  2213. try {
  2214. if (actual instanceof expected) {
  2215. return true;
  2216. }
  2217. } catch (e) {
  2218. // Ignore. The instanceof check doesn't work for arrow functions.
  2219. }
  2220. if (Error.isPrototypeOf(expected)) {
  2221. return false;
  2222. }
  2223. return expected.call({}, actual) === true;
  2224. }
  2225. function _tryBlock(block) {
  2226. var error;
  2227. try {
  2228. block();
  2229. } catch (e) {
  2230. error = e;
  2231. }
  2232. return error;
  2233. }
  2234. function _throws(shouldThrow, block, expected, message) {
  2235. var actual;
  2236. if (typeof block !== 'function') {
  2237. throw new TypeError('"block" argument must be a function');
  2238. }
  2239. if (typeof expected === 'string') {
  2240. message = expected;
  2241. expected = null;
  2242. }
  2243. actual = _tryBlock(block);
  2244. message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
  2245. (message ? ' ' + message : '.');
  2246. if (shouldThrow && !actual) {
  2247. fail(actual, expected, 'Missing expected exception' + message);
  2248. }
  2249. var userProvidedMessage = typeof message === 'string';
  2250. var isUnwantedException = !shouldThrow && util.isError(actual);
  2251. var isUnexpectedException = !shouldThrow && actual && !expected;
  2252. if ((isUnwantedException &&
  2253. userProvidedMessage &&
  2254. expectedException(actual, expected)) ||
  2255. isUnexpectedException) {
  2256. fail(actual, expected, 'Got unwanted exception' + message);
  2257. }
  2258. if ((shouldThrow && actual && expected &&
  2259. !expectedException(actual, expected)) || (!shouldThrow && actual)) {
  2260. throw actual;
  2261. }
  2262. }
  2263. // 11. Expected to throw an error:
  2264. // assert.throws(block, Error_opt, message_opt);
  2265. assert.throws = function(block, /*optional*/error, /*optional*/message) {
  2266. _throws(true, block, error, message);
  2267. };
  2268. // EXTENSION! This is annoying to write outside this module.
  2269. assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
  2270. _throws(false, block, error, message);
  2271. };
  2272. assert.ifError = function(err) { if (err) throw err; };
  2273. var objectKeys = Object.keys || function (obj) {
  2274. var keys = [];
  2275. for (var key in obj) {
  2276. if (hasOwn.call(obj, key)) keys.push(key);
  2277. }
  2278. return keys;
  2279. };
  2280. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2281. },{"util/":8}],6:[function(require,module,exports){
  2282. if (typeof Object.create === 'function') {
  2283. // implementation from standard node.js 'util' module
  2284. module.exports = function inherits(ctor, superCtor) {
  2285. ctor.super_ = superCtor
  2286. ctor.prototype = Object.create(superCtor.prototype, {
  2287. constructor: {
  2288. value: ctor,
  2289. enumerable: false,
  2290. writable: true,
  2291. configurable: true
  2292. }
  2293. });
  2294. };
  2295. } else {
  2296. // old school shim for old browsers
  2297. module.exports = function inherits(ctor, superCtor) {
  2298. ctor.super_ = superCtor
  2299. var TempCtor = function () {}
  2300. TempCtor.prototype = superCtor.prototype
  2301. ctor.prototype = new TempCtor()
  2302. ctor.prototype.constructor = ctor
  2303. }
  2304. }
  2305. },{}],7:[function(require,module,exports){
  2306. module.exports = function isBuffer(arg) {
  2307. return arg && typeof arg === 'object'
  2308. && typeof arg.copy === 'function'
  2309. && typeof arg.fill === 'function'
  2310. && typeof arg.readUInt8 === 'function';
  2311. }
  2312. },{}],8:[function(require,module,exports){
  2313. (function (process,global){
  2314. // Copyright Joyent, Inc. and other Node contributors.
  2315. //
  2316. // Permission is hereby granted, free of charge, to any person obtaining a
  2317. // copy of this software and associated documentation files (the
  2318. // "Software"), to deal in the Software without restriction, including
  2319. // without limitation the rights to use, copy, modify, merge, publish,
  2320. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2321. // persons to whom the Software is furnished to do so, subject to the
  2322. // following conditions:
  2323. //
  2324. // The above copyright notice and this permission notice shall be included
  2325. // in all copies or substantial portions of the Software.
  2326. //
  2327. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2328. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2329. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2330. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2331. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2332. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2333. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2334. var formatRegExp = /%[sdj%]/g;
  2335. exports.format = function(f) {
  2336. if (!isString(f)) {
  2337. var objects = [];
  2338. for (var i = 0; i < arguments.length; i++) {
  2339. objects.push(inspect(arguments[i]));
  2340. }
  2341. return objects.join(' ');
  2342. }
  2343. var i = 1;
  2344. var args = arguments;
  2345. var len = args.length;
  2346. var str = String(f).replace(formatRegExp, function(x) {
  2347. if (x === '%%') return '%';
  2348. if (i >= len) return x;
  2349. switch (x) {
  2350. case '%s': return String(args[i++]);
  2351. case '%d': return Number(args[i++]);
  2352. case '%j':
  2353. try {
  2354. return JSON.stringify(args[i++]);
  2355. } catch (_) {
  2356. return '[Circular]';
  2357. }
  2358. default:
  2359. return x;
  2360. }
  2361. });
  2362. for (var x = args[i]; i < len; x = args[++i]) {
  2363. if (isNull(x) || !isObject(x)) {
  2364. str += ' ' + x;
  2365. } else {
  2366. str += ' ' + inspect(x);
  2367. }
  2368. }
  2369. return str;
  2370. };
  2371. // Mark that a method should not be used.
  2372. // Returns a modified function which warns once by default.
  2373. // If --no-deprecation is set, then it is a no-op.
  2374. exports.deprecate = function(fn, msg) {
  2375. // Allow for deprecating things in the process of starting up.
  2376. if (isUndefined(global.process)) {
  2377. return function() {
  2378. return exports.deprecate(fn, msg).apply(this, arguments);
  2379. };
  2380. }
  2381. if (process.noDeprecation === true) {
  2382. return fn;
  2383. }
  2384. var warned = false;
  2385. function deprecated() {
  2386. if (!warned) {
  2387. if (process.throwDeprecation) {
  2388. throw new Error(msg);
  2389. } else if (process.traceDeprecation) {
  2390. console.trace(msg);
  2391. } else {
  2392. console.error(msg);
  2393. }
  2394. warned = true;
  2395. }
  2396. return fn.apply(this, arguments);
  2397. }
  2398. return deprecated;
  2399. };
  2400. var debugs = {};
  2401. var debugEnviron;
  2402. exports.debuglog = function(set) {
  2403. if (isUndefined(debugEnviron))
  2404. debugEnviron = process.env.NODE_DEBUG || '';
  2405. set = set.toUpperCase();
  2406. if (!debugs[set]) {
  2407. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  2408. var pid = process.pid;
  2409. debugs[set] = function() {
  2410. var msg = exports.format.apply(exports, arguments);
  2411. console.error('%s %d: %s', set, pid, msg);
  2412. };
  2413. } else {
  2414. debugs[set] = function() {};
  2415. }
  2416. }
  2417. return debugs[set];
  2418. };
  2419. /**
  2420. * Echos the value of a value. Trys to print the value out
  2421. * in the best way possible given the different types.
  2422. *
  2423. * @param {Object} obj The object to print out.
  2424. * @param {Object} opts Optional options object that alters the output.
  2425. */
  2426. /* legacy: obj, showHidden, depth, colors*/
  2427. function inspect(obj, opts) {
  2428. // default options
  2429. var ctx = {
  2430. seen: [],
  2431. stylize: stylizeNoColor
  2432. };
  2433. // legacy...
  2434. if (arguments.length >= 3) ctx.depth = arguments[2];
  2435. if (arguments.length >= 4) ctx.colors = arguments[3];
  2436. if (isBoolean(opts)) {
  2437. // legacy...
  2438. ctx.showHidden = opts;
  2439. } else if (opts) {
  2440. // got an "options" object
  2441. exports._extend(ctx, opts);
  2442. }
  2443. // set default options
  2444. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  2445. if (isUndefined(ctx.depth)) ctx.depth = 2;
  2446. if (isUndefined(ctx.colors)) ctx.colors = false;
  2447. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  2448. if (ctx.colors) ctx.stylize = stylizeWithColor;
  2449. return formatValue(ctx, obj, ctx.depth);
  2450. }
  2451. exports.inspect = inspect;
  2452. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  2453. inspect.colors = {
  2454. 'bold' : [1, 22],
  2455. 'italic' : [3, 23],
  2456. 'underline' : [4, 24],
  2457. 'inverse' : [7, 27],
  2458. 'white' : [37, 39],
  2459. 'grey' : [90, 39],
  2460. 'black' : [30, 39],
  2461. 'blue' : [34, 39],
  2462. 'cyan' : [36, 39],
  2463. 'green' : [32, 39],
  2464. 'magenta' : [35, 39],
  2465. 'red' : [31, 39],
  2466. 'yellow' : [33, 39]
  2467. };
  2468. // Don't use 'blue' not visible on cmd.exe
  2469. inspect.styles = {
  2470. 'special': 'cyan',
  2471. 'number': 'yellow',
  2472. 'boolean': 'yellow',
  2473. 'undefined': 'grey',
  2474. 'null': 'bold',
  2475. 'string': 'green',
  2476. 'date': 'magenta',
  2477. // "name": intentionally not styling
  2478. 'regexp': 'red'
  2479. };
  2480. function stylizeWithColor(str, styleType) {
  2481. var style = inspect.styles[styleType];
  2482. if (style) {
  2483. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  2484. '\u001b[' + inspect.colors[style][1] + 'm';
  2485. } else {
  2486. return str;
  2487. }
  2488. }
  2489. function stylizeNoColor(str, styleType) {
  2490. return str;
  2491. }
  2492. function arrayToHash(array) {
  2493. var hash = {};
  2494. array.forEach(function(val, idx) {
  2495. hash[val] = true;
  2496. });
  2497. return hash;
  2498. }
  2499. function formatValue(ctx, value, recurseTimes) {
  2500. // Provide a hook for user-specified inspect functions.
  2501. // Check that value is an object with an inspect function on it
  2502. if (ctx.customInspect &&
  2503. value &&
  2504. isFunction(value.inspect) &&
  2505. // Filter out the util module, it's inspect function is special
  2506. value.inspect !== exports.inspect &&
  2507. // Also filter out any prototype objects using the circular check.
  2508. !(value.constructor && value.constructor.prototype === value)) {
  2509. var ret = value.inspect(recurseTimes, ctx);
  2510. if (!isString(ret)) {
  2511. ret = formatValue(ctx, ret, recurseTimes);
  2512. }
  2513. return ret;
  2514. }
  2515. // Primitive types cannot have properties
  2516. var primitive = formatPrimitive(ctx, value);
  2517. if (primitive) {
  2518. return primitive;
  2519. }
  2520. // Look up the keys of the object.
  2521. var keys = Object.keys(value);
  2522. var visibleKeys = arrayToHash(keys);
  2523. if (ctx.showHidden) {
  2524. keys = Object.getOwnPropertyNames(value);
  2525. }
  2526. // IE doesn't make error fields non-enumerable
  2527. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  2528. if (isError(value)
  2529. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  2530. return formatError(value);
  2531. }
  2532. // Some type of object without properties can be shortcutted.
  2533. if (keys.length === 0) {
  2534. if (isFunction(value)) {
  2535. var name = value.name ? ': ' + value.name : '';
  2536. return ctx.stylize('[Function' + name + ']', 'special');
  2537. }
  2538. if (isRegExp(value)) {
  2539. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  2540. }
  2541. if (isDate(value)) {
  2542. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  2543. }
  2544. if (isError(value)) {
  2545. return formatError(value);
  2546. }
  2547. }
  2548. var base = '', array = false, braces = ['{', '}'];
  2549. // Make Array say that they are Array
  2550. if (isArray(value)) {
  2551. array = true;
  2552. braces = ['[', ']'];
  2553. }
  2554. // Make functions say that they are functions
  2555. if (isFunction(value)) {
  2556. var n = value.name ? ': ' + value.name : '';
  2557. base = ' [Function' + n + ']';
  2558. }
  2559. // Make RegExps say that they are RegExps
  2560. if (isRegExp(value)) {
  2561. base = ' ' + RegExp.prototype.toString.call(value);
  2562. }
  2563. // Make dates with properties first say the date
  2564. if (isDate(value)) {
  2565. base = ' ' + Date.prototype.toUTCString.call(value);
  2566. }
  2567. // Make error with message first say the error
  2568. if (isError(value)) {
  2569. base = ' ' + formatError(value);
  2570. }
  2571. if (keys.length === 0 && (!array || value.length == 0)) {
  2572. return braces[0] + base + braces[1];
  2573. }
  2574. if (recurseTimes < 0) {
  2575. if (isRegExp(value)) {
  2576. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  2577. } else {
  2578. return ctx.stylize('[Object]', 'special');
  2579. }
  2580. }
  2581. ctx.seen.push(value);
  2582. var output;
  2583. if (array) {
  2584. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  2585. } else {
  2586. output = keys.map(function(key) {
  2587. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  2588. });
  2589. }
  2590. ctx.seen.pop();
  2591. return reduceToSingleString(output, base, braces);
  2592. }
  2593. function formatPrimitive(ctx, value) {
  2594. if (isUndefined(value))
  2595. return ctx.stylize('undefined', 'undefined');
  2596. if (isString(value)) {
  2597. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  2598. .replace(/'/g, "\\'")
  2599. .replace(/\\"/g, '"') + '\'';
  2600. return ctx.stylize(simple, 'string');
  2601. }
  2602. if (isNumber(value))
  2603. return ctx.stylize('' + value, 'number');
  2604. if (isBoolean(value))
  2605. return ctx.stylize('' + value, 'boolean');
  2606. // For some reason typeof null is "object", so special case here.
  2607. if (isNull(value))
  2608. return ctx.stylize('null', 'null');
  2609. }
  2610. function formatError(value) {
  2611. return '[' + Error.prototype.toString.call(value) + ']';
  2612. }
  2613. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  2614. var output = [];
  2615. for (var i = 0, l = value.length; i < l; ++i) {
  2616. if (hasOwnProperty(value, String(i))) {
  2617. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  2618. String(i), true));
  2619. } else {
  2620. output.push('');
  2621. }
  2622. }
  2623. keys.forEach(function(key) {
  2624. if (!key.match(/^\d+$/)) {
  2625. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  2626. key, true));
  2627. }
  2628. });
  2629. return output;
  2630. }
  2631. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  2632. var name, str, desc;
  2633. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  2634. if (desc.get) {
  2635. if (desc.set) {
  2636. str = ctx.stylize('[Getter/Setter]', 'special');
  2637. } else {
  2638. str = ctx.stylize('[Getter]', 'special');
  2639. }
  2640. } else {
  2641. if (desc.set) {
  2642. str = ctx.stylize('[Setter]', 'special');
  2643. }
  2644. }
  2645. if (!hasOwnProperty(visibleKeys, key)) {
  2646. name = '[' + key + ']';
  2647. }
  2648. if (!str) {
  2649. if (ctx.seen.indexOf(desc.value) < 0) {
  2650. if (isNull(recurseTimes)) {
  2651. str = formatValue(ctx, desc.value, null);
  2652. } else {
  2653. str = formatValue(ctx, desc.value, recurseTimes - 1);
  2654. }
  2655. if (str.indexOf('\n') > -1) {
  2656. if (array) {
  2657. str = str.split('\n').map(function(line) {
  2658. return ' ' + line;
  2659. }).join('\n').substr(2);
  2660. } else {
  2661. str = '\n' + str.split('\n').map(function(line) {
  2662. return ' ' + line;
  2663. }).join('\n');
  2664. }
  2665. }
  2666. } else {
  2667. str = ctx.stylize('[Circular]', 'special');
  2668. }
  2669. }
  2670. if (isUndefined(name)) {
  2671. if (array && key.match(/^\d+$/)) {
  2672. return str;
  2673. }
  2674. name = JSON.stringify('' + key);
  2675. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  2676. name = name.substr(1, name.length - 2);
  2677. name = ctx.stylize(name, 'name');
  2678. } else {
  2679. name = name.replace(/'/g, "\\'")
  2680. .replace(/\\"/g, '"')
  2681. .replace(/(^"|"$)/g, "'");
  2682. name = ctx.stylize(name, 'string');
  2683. }
  2684. }
  2685. return name + ': ' + str;
  2686. }
  2687. function reduceToSingleString(output, base, braces) {
  2688. var numLinesEst = 0;
  2689. var length = output.reduce(function(prev, cur) {
  2690. numLinesEst++;
  2691. if (cur.indexOf('\n') >= 0) numLinesEst++;
  2692. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  2693. }, 0);
  2694. if (length > 60) {
  2695. return braces[0] +
  2696. (base === '' ? '' : base + '\n ') +
  2697. ' ' +
  2698. output.join(',\n ') +
  2699. ' ' +
  2700. braces[1];
  2701. }
  2702. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  2703. }
  2704. // NOTE: These type checking functions intentionally don't use `instanceof`
  2705. // because it is fragile and can be easily faked with `Object.create()`.
  2706. function isArray(ar) {
  2707. return Array.isArray(ar);
  2708. }
  2709. exports.isArray = isArray;
  2710. function isBoolean(arg) {
  2711. return typeof arg === 'boolean';
  2712. }
  2713. exports.isBoolean = isBoolean;
  2714. function isNull(arg) {
  2715. return arg === null;
  2716. }
  2717. exports.isNull = isNull;
  2718. function isNullOrUndefined(arg) {
  2719. return arg == null;
  2720. }
  2721. exports.isNullOrUndefined = isNullOrUndefined;
  2722. function isNumber(arg) {
  2723. return typeof arg === 'number';
  2724. }
  2725. exports.isNumber = isNumber;
  2726. function isString(arg) {
  2727. return typeof arg === 'string';
  2728. }
  2729. exports.isString = isString;
  2730. function isSymbol(arg) {
  2731. return typeof arg === 'symbol';
  2732. }
  2733. exports.isSymbol = isSymbol;
  2734. function isUndefined(arg) {
  2735. return arg === void 0;
  2736. }
  2737. exports.isUndefined = isUndefined;
  2738. function isRegExp(re) {
  2739. return isObject(re) && objectToString(re) === '[object RegExp]';
  2740. }
  2741. exports.isRegExp = isRegExp;
  2742. function isObject(arg) {
  2743. return typeof arg === 'object' && arg !== null;
  2744. }
  2745. exports.isObject = isObject;
  2746. function isDate(d) {
  2747. return isObject(d) && objectToString(d) === '[object Date]';
  2748. }
  2749. exports.isDate = isDate;
  2750. function isError(e) {
  2751. return isObject(e) &&
  2752. (objectToString(e) === '[object Error]' || e instanceof Error);
  2753. }
  2754. exports.isError = isError;
  2755. function isFunction(arg) {
  2756. return typeof arg === 'function';
  2757. }
  2758. exports.isFunction = isFunction;
  2759. function isPrimitive(arg) {
  2760. return arg === null ||
  2761. typeof arg === 'boolean' ||
  2762. typeof arg === 'number' ||
  2763. typeof arg === 'string' ||
  2764. typeof arg === 'symbol' || // ES6 symbol
  2765. typeof arg === 'undefined';
  2766. }
  2767. exports.isPrimitive = isPrimitive;
  2768. exports.isBuffer = require('./support/isBuffer');
  2769. function objectToString(o) {
  2770. return Object.prototype.toString.call(o);
  2771. }
  2772. function pad(n) {
  2773. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  2774. }
  2775. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  2776. 'Oct', 'Nov', 'Dec'];
  2777. // 26 Feb 16:19:34
  2778. function timestamp() {
  2779. var d = new Date();
  2780. var time = [pad(d.getHours()),
  2781. pad(d.getMinutes()),
  2782. pad(d.getSeconds())].join(':');
  2783. return [d.getDate(), months[d.getMonth()], time].join(' ');
  2784. }
  2785. // log is just a thin wrapper to console.log that prepends a timestamp
  2786. exports.log = function() {
  2787. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  2788. };
  2789. /**
  2790. * Inherit the prototype methods from one constructor into another.
  2791. *
  2792. * The Function.prototype.inherits from lang.js rewritten as a standalone
  2793. * function (not on Function.prototype). NOTE: If this file is to be loaded
  2794. * during bootstrapping this function needs to be rewritten using some native
  2795. * functions as prototype setup using normal JavaScript does not work as
  2796. * expected during bootstrapping (see mirror.js in r114903).
  2797. *
  2798. * @param {function} ctor Constructor function which needs to inherit the
  2799. * prototype.
  2800. * @param {function} superCtor Constructor function to inherit prototype from.
  2801. */
  2802. exports.inherits = require('inherits');
  2803. exports._extend = function(origin, add) {
  2804. // Don't do anything if add isn't an object
  2805. if (!add || !isObject(add)) return origin;
  2806. var keys = Object.keys(add);
  2807. var i = keys.length;
  2808. while (i--) {
  2809. origin[keys[i]] = add[keys[i]];
  2810. }
  2811. return origin;
  2812. };
  2813. function hasOwnProperty(obj, prop) {
  2814. return Object.prototype.hasOwnProperty.call(obj, prop);
  2815. }
  2816. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2817. },{"./support/isBuffer":7,"_process":12,"inherits":6}],9:[function(require,module,exports){
  2818. 'use strict'
  2819. exports.byteLength = byteLength
  2820. exports.toByteArray = toByteArray
  2821. exports.fromByteArray = fromByteArray
  2822. var lookup = []
  2823. var revLookup = []
  2824. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  2825. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  2826. for (var i = 0, len = code.length; i < len; ++i) {
  2827. lookup[i] = code[i]
  2828. revLookup[code.charCodeAt(i)] = i
  2829. }
  2830. // Support decoding URL-safe base64 strings, as Node.js does.
  2831. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  2832. revLookup['-'.charCodeAt(0)] = 62
  2833. revLookup['_'.charCodeAt(0)] = 63
  2834. function getLens (b64) {
  2835. var len = b64.length
  2836. if (len % 4 > 0) {
  2837. throw new Error('Invalid string. Length must be a multiple of 4')
  2838. }
  2839. // Trim off extra bytes after placeholder bytes are found
  2840. // See: https://github.com/beatgammit/base64-js/issues/42
  2841. var validLen = b64.indexOf('=')
  2842. if (validLen === -1) validLen = len
  2843. var placeHoldersLen = validLen === len
  2844. ? 0
  2845. : 4 - (validLen % 4)
  2846. return [validLen, placeHoldersLen]
  2847. }
  2848. // base64 is 4/3 + up to two characters of the original data
  2849. function byteLength (b64) {
  2850. var lens = getLens(b64)
  2851. var validLen = lens[0]
  2852. var placeHoldersLen = lens[1]
  2853. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  2854. }
  2855. function _byteLength (b64, validLen, placeHoldersLen) {
  2856. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  2857. }
  2858. function toByteArray (b64) {
  2859. var tmp
  2860. var lens = getLens(b64)
  2861. var validLen = lens[0]
  2862. var placeHoldersLen = lens[1]
  2863. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  2864. var curByte = 0
  2865. // if there are placeholders, only get up to the last complete 4 chars
  2866. var len = placeHoldersLen > 0
  2867. ? validLen - 4
  2868. : validLen
  2869. for (var i = 0; i < len; i += 4) {
  2870. tmp =
  2871. (revLookup[b64.charCodeAt(i)] << 18) |
  2872. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  2873. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  2874. revLookup[b64.charCodeAt(i + 3)]
  2875. arr[curByte++] = (tmp >> 16) & 0xFF
  2876. arr[curByte++] = (tmp >> 8) & 0xFF
  2877. arr[curByte++] = tmp & 0xFF
  2878. }
  2879. if (placeHoldersLen === 2) {
  2880. tmp =
  2881. (revLookup[b64.charCodeAt(i)] << 2) |
  2882. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  2883. arr[curByte++] = tmp & 0xFF
  2884. }
  2885. if (placeHoldersLen === 1) {
  2886. tmp =
  2887. (revLookup[b64.charCodeAt(i)] << 10) |
  2888. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  2889. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  2890. arr[curByte++] = (tmp >> 8) & 0xFF
  2891. arr[curByte++] = tmp & 0xFF
  2892. }
  2893. return arr
  2894. }
  2895. function tripletToBase64 (num) {
  2896. return lookup[num >> 18 & 0x3F] +
  2897. lookup[num >> 12 & 0x3F] +
  2898. lookup[num >> 6 & 0x3F] +
  2899. lookup[num & 0x3F]
  2900. }
  2901. function encodeChunk (uint8, start, end) {
  2902. var tmp
  2903. var output = []
  2904. for (var i = start; i < end; i += 3) {
  2905. tmp =
  2906. ((uint8[i] << 16) & 0xFF0000) +
  2907. ((uint8[i + 1] << 8) & 0xFF00) +
  2908. (uint8[i + 2] & 0xFF)
  2909. output.push(tripletToBase64(tmp))
  2910. }
  2911. return output.join('')
  2912. }
  2913. function fromByteArray (uint8) {
  2914. var tmp
  2915. var len = uint8.length
  2916. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  2917. var parts = []
  2918. var maxChunkLength = 16383 // must be multiple of 3
  2919. // go through the array every three bytes, we'll deal with trailing stuff later
  2920. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  2921. parts.push(encodeChunk(
  2922. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  2923. ))
  2924. }
  2925. // pad the end with zeros, but make sure to not forget the extra bytes
  2926. if (extraBytes === 1) {
  2927. tmp = uint8[len - 1]
  2928. parts.push(
  2929. lookup[tmp >> 2] +
  2930. lookup[(tmp << 4) & 0x3F] +
  2931. '=='
  2932. )
  2933. } else if (extraBytes === 2) {
  2934. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  2935. parts.push(
  2936. lookup[tmp >> 10] +
  2937. lookup[(tmp >> 4) & 0x3F] +
  2938. lookup[(tmp << 2) & 0x3F] +
  2939. '='
  2940. )
  2941. }
  2942. return parts.join('')
  2943. }
  2944. },{}],10:[function(require,module,exports){
  2945. (function (Buffer){
  2946. /*!
  2947. * The buffer module from node.js, for the browser.
  2948. *
  2949. * @author Feross Aboukhadijeh <https://feross.org>
  2950. * @license MIT
  2951. */
  2952. /* eslint-disable no-proto */
  2953. 'use strict'
  2954. var base64 = require('base64-js')
  2955. var ieee754 = require('ieee754')
  2956. exports.Buffer = Buffer
  2957. exports.SlowBuffer = SlowBuffer
  2958. exports.INSPECT_MAX_BYTES = 50
  2959. var K_MAX_LENGTH = 0x7fffffff
  2960. exports.kMaxLength = K_MAX_LENGTH
  2961. /**
  2962. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  2963. * === true Use Uint8Array implementation (fastest)
  2964. * === false Print warning and recommend using `buffer` v4.x which has an Object
  2965. * implementation (most compatible, even IE6)
  2966. *
  2967. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  2968. * Opera 11.6+, iOS 4.2+.
  2969. *
  2970. * We report that the browser does not support typed arrays if the are not subclassable
  2971. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  2972. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  2973. * for __proto__ and has a buggy typed array implementation.
  2974. */
  2975. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  2976. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  2977. typeof console.error === 'function') {
  2978. console.error(
  2979. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  2980. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  2981. )
  2982. }
  2983. function typedArraySupport () {
  2984. // Can typed array instances can be augmented?
  2985. try {
  2986. var arr = new Uint8Array(1)
  2987. arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
  2988. return arr.foo() === 42
  2989. } catch (e) {
  2990. return false
  2991. }
  2992. }
  2993. Object.defineProperty(Buffer.prototype, 'parent', {
  2994. enumerable: true,
  2995. get: function () {
  2996. if (!Buffer.isBuffer(this)) return undefined
  2997. return this.buffer
  2998. }
  2999. })
  3000. Object.defineProperty(Buffer.prototype, 'offset', {
  3001. enumerable: true,
  3002. get: function () {
  3003. if (!Buffer.isBuffer(this)) return undefined
  3004. return this.byteOffset
  3005. }
  3006. })
  3007. function createBuffer (length) {
  3008. if (length > K_MAX_LENGTH) {
  3009. throw new RangeError('The value "' + length + '" is invalid for option "size"')
  3010. }
  3011. // Return an augmented `Uint8Array` instance
  3012. var buf = new Uint8Array(length)
  3013. buf.__proto__ = Buffer.prototype
  3014. return buf
  3015. }
  3016. /**
  3017. * The Buffer constructor returns instances of `Uint8Array` that have their
  3018. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  3019. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  3020. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  3021. * returns a single octet.
  3022. *
  3023. * The `Uint8Array` prototype remains unmodified.
  3024. */
  3025. function Buffer (arg, encodingOrOffset, length) {
  3026. // Common case.
  3027. if (typeof arg === 'number') {
  3028. if (typeof encodingOrOffset === 'string') {
  3029. throw new TypeError(
  3030. 'The "string" argument must be of type string. Received type number'
  3031. )
  3032. }
  3033. return allocUnsafe(arg)
  3034. }
  3035. return from(arg, encodingOrOffset, length)
  3036. }
  3037. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  3038. if (typeof Symbol !== 'undefined' && Symbol.species != null &&
  3039. Buffer[Symbol.species] === Buffer) {
  3040. Object.defineProperty(Buffer, Symbol.species, {
  3041. value: null,
  3042. configurable: true,
  3043. enumerable: false,
  3044. writable: false
  3045. })
  3046. }
  3047. Buffer.poolSize = 8192 // not used by this implementation
  3048. function from (value, encodingOrOffset, length) {
  3049. if (typeof value === 'string') {
  3050. return fromString(value, encodingOrOffset)
  3051. }
  3052. if (ArrayBuffer.isView(value)) {
  3053. return fromArrayLike(value)
  3054. }
  3055. if (value == null) {
  3056. throw TypeError(
  3057. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  3058. 'or Array-like Object. Received type ' + (typeof value)
  3059. )
  3060. }
  3061. if (isInstance(value, ArrayBuffer) ||
  3062. (value && isInstance(value.buffer, ArrayBuffer))) {
  3063. return fromArrayBuffer(value, encodingOrOffset, length)
  3064. }
  3065. if (typeof value === 'number') {
  3066. throw new TypeError(
  3067. 'The "value" argument must not be of type number. Received type number'
  3068. )
  3069. }
  3070. var valueOf = value.valueOf && value.valueOf()
  3071. if (valueOf != null && valueOf !== value) {
  3072. return Buffer.from(valueOf, encodingOrOffset, length)
  3073. }
  3074. var b = fromObject(value)
  3075. if (b) return b
  3076. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  3077. typeof value[Symbol.toPrimitive] === 'function') {
  3078. return Buffer.from(
  3079. value[Symbol.toPrimitive]('string'), encodingOrOffset, length
  3080. )
  3081. }
  3082. throw new TypeError(
  3083. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  3084. 'or Array-like Object. Received type ' + (typeof value)
  3085. )
  3086. }
  3087. /**
  3088. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  3089. * if value is a number.
  3090. * Buffer.from(str[, encoding])
  3091. * Buffer.from(array)
  3092. * Buffer.from(buffer)
  3093. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  3094. **/
  3095. Buffer.from = function (value, encodingOrOffset, length) {
  3096. return from(value, encodingOrOffset, length)
  3097. }
  3098. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  3099. // https://github.com/feross/buffer/pull/148
  3100. Buffer.prototype.__proto__ = Uint8Array.prototype
  3101. Buffer.__proto__ = Uint8Array
  3102. function assertSize (size) {
  3103. if (typeof size !== 'number') {
  3104. throw new TypeError('"size" argument must be of type number')
  3105. } else if (size < 0) {
  3106. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  3107. }
  3108. }
  3109. function alloc (size, fill, encoding) {
  3110. assertSize(size)
  3111. if (size <= 0) {
  3112. return createBuffer(size)
  3113. }
  3114. if (fill !== undefined) {
  3115. // Only pay attention to encoding if it's a string. This
  3116. // prevents accidentally sending in a number that would
  3117. // be interpretted as a start offset.
  3118. return typeof encoding === 'string'
  3119. ? createBuffer(size).fill(fill, encoding)
  3120. : createBuffer(size).fill(fill)
  3121. }
  3122. return createBuffer(size)
  3123. }
  3124. /**
  3125. * Creates a new filled Buffer instance.
  3126. * alloc(size[, fill[, encoding]])
  3127. **/
  3128. Buffer.alloc = function (size, fill, encoding) {
  3129. return alloc(size, fill, encoding)
  3130. }
  3131. function allocUnsafe (size) {
  3132. assertSize(size)
  3133. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  3134. }
  3135. /**
  3136. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  3137. * */
  3138. Buffer.allocUnsafe = function (size) {
  3139. return allocUnsafe(size)
  3140. }
  3141. /**
  3142. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  3143. */
  3144. Buffer.allocUnsafeSlow = function (size) {
  3145. return allocUnsafe(size)
  3146. }
  3147. function fromString (string, encoding) {
  3148. if (typeof encoding !== 'string' || encoding === '') {
  3149. encoding = 'utf8'
  3150. }
  3151. if (!Buffer.isEncoding(encoding)) {
  3152. throw new TypeError('Unknown encoding: ' + encoding)
  3153. }
  3154. var length = byteLength(string, encoding) | 0
  3155. var buf = createBuffer(length)
  3156. var actual = buf.write(string, encoding)
  3157. if (actual !== length) {
  3158. // Writing a hex string, for example, that contains invalid characters will
  3159. // cause everything after the first invalid character to be ignored. (e.g.
  3160. // 'abxxcd' will be treated as 'ab')
  3161. buf = buf.slice(0, actual)
  3162. }
  3163. return buf
  3164. }
  3165. function fromArrayLike (array) {
  3166. var length = array.length < 0 ? 0 : checked(array.length) | 0
  3167. var buf = createBuffer(length)
  3168. for (var i = 0; i < length; i += 1) {
  3169. buf[i] = array[i] & 255
  3170. }
  3171. return buf
  3172. }
  3173. function fromArrayBuffer (array, byteOffset, length) {
  3174. if (byteOffset < 0 || array.byteLength < byteOffset) {
  3175. throw new RangeError('"offset" is outside of buffer bounds')
  3176. }
  3177. if (array.byteLength < byteOffset + (length || 0)) {
  3178. throw new RangeError('"length" is outside of buffer bounds')
  3179. }
  3180. var buf
  3181. if (byteOffset === undefined && length === undefined) {
  3182. buf = new Uint8Array(array)
  3183. } else if (length === undefined) {
  3184. buf = new Uint8Array(array, byteOffset)
  3185. } else {
  3186. buf = new Uint8Array(array, byteOffset, length)
  3187. }
  3188. // Return an augmented `Uint8Array` instance
  3189. buf.__proto__ = Buffer.prototype
  3190. return buf
  3191. }
  3192. function fromObject (obj) {
  3193. if (Buffer.isBuffer(obj)) {
  3194. var len = checked(obj.length) | 0
  3195. var buf = createBuffer(len)
  3196. if (buf.length === 0) {
  3197. return buf
  3198. }
  3199. obj.copy(buf, 0, 0, len)
  3200. return buf
  3201. }
  3202. if (obj.length !== undefined) {
  3203. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  3204. return createBuffer(0)
  3205. }
  3206. return fromArrayLike(obj)
  3207. }
  3208. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  3209. return fromArrayLike(obj.data)
  3210. }
  3211. }
  3212. function checked (length) {
  3213. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  3214. // length is NaN (which is otherwise coerced to zero.)
  3215. if (length >= K_MAX_LENGTH) {
  3216. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  3217. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  3218. }
  3219. return length | 0
  3220. }
  3221. function SlowBuffer (length) {
  3222. if (+length != length) { // eslint-disable-line eqeqeq
  3223. length = 0
  3224. }
  3225. return Buffer.alloc(+length)
  3226. }
  3227. Buffer.isBuffer = function isBuffer (b) {
  3228. return b != null && b._isBuffer === true &&
  3229. b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
  3230. }
  3231. Buffer.compare = function compare (a, b) {
  3232. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
  3233. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
  3234. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  3235. throw new TypeError(
  3236. 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
  3237. )
  3238. }
  3239. if (a === b) return 0
  3240. var x = a.length
  3241. var y = b.length
  3242. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  3243. if (a[i] !== b[i]) {
  3244. x = a[i]
  3245. y = b[i]
  3246. break
  3247. }
  3248. }
  3249. if (x < y) return -1
  3250. if (y < x) return 1
  3251. return 0
  3252. }
  3253. Buffer.isEncoding = function isEncoding (encoding) {
  3254. switch (String(encoding).toLowerCase()) {
  3255. case 'hex':
  3256. case 'utf8':
  3257. case 'utf-8':
  3258. case 'ascii':
  3259. case 'latin1':
  3260. case 'binary':
  3261. case 'base64':
  3262. case 'ucs2':
  3263. case 'ucs-2':
  3264. case 'utf16le':
  3265. case 'utf-16le':
  3266. return true
  3267. default:
  3268. return false
  3269. }
  3270. }
  3271. Buffer.concat = function concat (list, length) {
  3272. if (!Array.isArray(list)) {
  3273. throw new TypeError('"list" argument must be an Array of Buffers')
  3274. }
  3275. if (list.length === 0) {
  3276. return Buffer.alloc(0)
  3277. }
  3278. var i
  3279. if (length === undefined) {
  3280. length = 0
  3281. for (i = 0; i < list.length; ++i) {
  3282. length += list[i].length
  3283. }
  3284. }
  3285. var buffer = Buffer.allocUnsafe(length)
  3286. var pos = 0
  3287. for (i = 0; i < list.length; ++i) {
  3288. var buf = list[i]
  3289. if (isInstance(buf, Uint8Array)) {
  3290. buf = Buffer.from(buf)
  3291. }
  3292. if (!Buffer.isBuffer(buf)) {
  3293. throw new TypeError('"list" argument must be an Array of Buffers')
  3294. }
  3295. buf.copy(buffer, pos)
  3296. pos += buf.length
  3297. }
  3298. return buffer
  3299. }
  3300. function byteLength (string, encoding) {
  3301. if (Buffer.isBuffer(string)) {
  3302. return string.length
  3303. }
  3304. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  3305. return string.byteLength
  3306. }
  3307. if (typeof string !== 'string') {
  3308. throw new TypeError(
  3309. 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  3310. 'Received type ' + typeof string
  3311. )
  3312. }
  3313. var len = string.length
  3314. var mustMatch = (arguments.length > 2 && arguments[2] === true)
  3315. if (!mustMatch && len === 0) return 0
  3316. // Use a for loop to avoid recursion
  3317. var loweredCase = false
  3318. for (;;) {
  3319. switch (encoding) {
  3320. case 'ascii':
  3321. case 'latin1':
  3322. case 'binary':
  3323. return len
  3324. case 'utf8':
  3325. case 'utf-8':
  3326. return utf8ToBytes(string).length
  3327. case 'ucs2':
  3328. case 'ucs-2':
  3329. case 'utf16le':
  3330. case 'utf-16le':
  3331. return len * 2
  3332. case 'hex':
  3333. return len >>> 1
  3334. case 'base64':
  3335. return base64ToBytes(string).length
  3336. default:
  3337. if (loweredCase) {
  3338. return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
  3339. }
  3340. encoding = ('' + encoding).toLowerCase()
  3341. loweredCase = true
  3342. }
  3343. }
  3344. }
  3345. Buffer.byteLength = byteLength
  3346. function slowToString (encoding, start, end) {
  3347. var loweredCase = false
  3348. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  3349. // property of a typed array.
  3350. // This behaves neither like String nor Uint8Array in that we set start/end
  3351. // to their upper/lower bounds if the value passed is out of range.
  3352. // undefined is handled specially as per ECMA-262 6th Edition,
  3353. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  3354. if (start === undefined || start < 0) {
  3355. start = 0
  3356. }
  3357. // Return early if start > this.length. Done here to prevent potential uint32
  3358. // coercion fail below.
  3359. if (start > this.length) {
  3360. return ''
  3361. }
  3362. if (end === undefined || end > this.length) {
  3363. end = this.length
  3364. }
  3365. if (end <= 0) {
  3366. return ''
  3367. }
  3368. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  3369. end >>>= 0
  3370. start >>>= 0
  3371. if (end <= start) {
  3372. return ''
  3373. }
  3374. if (!encoding) encoding = 'utf8'
  3375. while (true) {
  3376. switch (encoding) {
  3377. case 'hex':
  3378. return hexSlice(this, start, end)
  3379. case 'utf8':
  3380. case 'utf-8':
  3381. return utf8Slice(this, start, end)
  3382. case 'ascii':
  3383. return asciiSlice(this, start, end)
  3384. case 'latin1':
  3385. case 'binary':
  3386. return latin1Slice(this, start, end)
  3387. case 'base64':
  3388. return base64Slice(this, start, end)
  3389. case 'ucs2':
  3390. case 'ucs-2':
  3391. case 'utf16le':
  3392. case 'utf-16le':
  3393. return utf16leSlice(this, start, end)
  3394. default:
  3395. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  3396. encoding = (encoding + '').toLowerCase()
  3397. loweredCase = true
  3398. }
  3399. }
  3400. }
  3401. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  3402. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  3403. // reliably in a browserify context because there could be multiple different
  3404. // copies of the 'buffer' package in use. This method works even for Buffer
  3405. // instances that were created from another copy of the `buffer` package.
  3406. // See: https://github.com/feross/buffer/issues/154
  3407. Buffer.prototype._isBuffer = true
  3408. function swap (b, n, m) {
  3409. var i = b[n]
  3410. b[n] = b[m]
  3411. b[m] = i
  3412. }
  3413. Buffer.prototype.swap16 = function swap16 () {
  3414. var len = this.length
  3415. if (len % 2 !== 0) {
  3416. throw new RangeError('Buffer size must be a multiple of 16-bits')
  3417. }
  3418. for (var i = 0; i < len; i += 2) {
  3419. swap(this, i, i + 1)
  3420. }
  3421. return this
  3422. }
  3423. Buffer.prototype.swap32 = function swap32 () {
  3424. var len = this.length
  3425. if (len % 4 !== 0) {
  3426. throw new RangeError('Buffer size must be a multiple of 32-bits')
  3427. }
  3428. for (var i = 0; i < len; i += 4) {
  3429. swap(this, i, i + 3)
  3430. swap(this, i + 1, i + 2)
  3431. }
  3432. return this
  3433. }
  3434. Buffer.prototype.swap64 = function swap64 () {
  3435. var len = this.length
  3436. if (len % 8 !== 0) {
  3437. throw new RangeError('Buffer size must be a multiple of 64-bits')
  3438. }
  3439. for (var i = 0; i < len; i += 8) {
  3440. swap(this, i, i + 7)
  3441. swap(this, i + 1, i + 6)
  3442. swap(this, i + 2, i + 5)
  3443. swap(this, i + 3, i + 4)
  3444. }
  3445. return this
  3446. }
  3447. Buffer.prototype.toString = function toString () {
  3448. var length = this.length
  3449. if (length === 0) return ''
  3450. if (arguments.length === 0) return utf8Slice(this, 0, length)
  3451. return slowToString.apply(this, arguments)
  3452. }
  3453. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  3454. Buffer.prototype.equals = function equals (b) {
  3455. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  3456. if (this === b) return true
  3457. return Buffer.compare(this, b) === 0
  3458. }
  3459. Buffer.prototype.inspect = function inspect () {
  3460. var str = ''
  3461. var max = exports.INSPECT_MAX_BYTES
  3462. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
  3463. if (this.length > max) str += ' ... '
  3464. return '<Buffer ' + str + '>'
  3465. }
  3466. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  3467. if (isInstance(target, Uint8Array)) {
  3468. target = Buffer.from(target, target.offset, target.byteLength)
  3469. }
  3470. if (!Buffer.isBuffer(target)) {
  3471. throw new TypeError(
  3472. 'The "target" argument must be one of type Buffer or Uint8Array. ' +
  3473. 'Received type ' + (typeof target)
  3474. )
  3475. }
  3476. if (start === undefined) {
  3477. start = 0
  3478. }
  3479. if (end === undefined) {
  3480. end = target ? target.length : 0
  3481. }
  3482. if (thisStart === undefined) {
  3483. thisStart = 0
  3484. }
  3485. if (thisEnd === undefined) {
  3486. thisEnd = this.length
  3487. }
  3488. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  3489. throw new RangeError('out of range index')
  3490. }
  3491. if (thisStart >= thisEnd && start >= end) {
  3492. return 0
  3493. }
  3494. if (thisStart >= thisEnd) {
  3495. return -1
  3496. }
  3497. if (start >= end) {
  3498. return 1
  3499. }
  3500. start >>>= 0
  3501. end >>>= 0
  3502. thisStart >>>= 0
  3503. thisEnd >>>= 0
  3504. if (this === target) return 0
  3505. var x = thisEnd - thisStart
  3506. var y = end - start
  3507. var len = Math.min(x, y)
  3508. var thisCopy = this.slice(thisStart, thisEnd)
  3509. var targetCopy = target.slice(start, end)
  3510. for (var i = 0; i < len; ++i) {
  3511. if (thisCopy[i] !== targetCopy[i]) {
  3512. x = thisCopy[i]
  3513. y = targetCopy[i]
  3514. break
  3515. }
  3516. }
  3517. if (x < y) return -1
  3518. if (y < x) return 1
  3519. return 0
  3520. }
  3521. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  3522. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  3523. //
  3524. // Arguments:
  3525. // - buffer - a Buffer to search
  3526. // - val - a string, Buffer, or number
  3527. // - byteOffset - an index into `buffer`; will be clamped to an int32
  3528. // - encoding - an optional encoding, relevant is val is a string
  3529. // - dir - true for indexOf, false for lastIndexOf
  3530. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  3531. // Empty buffer means no match
  3532. if (buffer.length === 0) return -1
  3533. // Normalize byteOffset
  3534. if (typeof byteOffset === 'string') {
  3535. encoding = byteOffset
  3536. byteOffset = 0
  3537. } else if (byteOffset > 0x7fffffff) {
  3538. byteOffset = 0x7fffffff
  3539. } else if (byteOffset < -0x80000000) {
  3540. byteOffset = -0x80000000
  3541. }
  3542. byteOffset = +byteOffset // Coerce to Number.
  3543. if (numberIsNaN(byteOffset)) {
  3544. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  3545. byteOffset = dir ? 0 : (buffer.length - 1)
  3546. }
  3547. // Normalize byteOffset: negative offsets start from the end of the buffer
  3548. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  3549. if (byteOffset >= buffer.length) {
  3550. if (dir) return -1
  3551. else byteOffset = buffer.length - 1
  3552. } else if (byteOffset < 0) {
  3553. if (dir) byteOffset = 0
  3554. else return -1
  3555. }
  3556. // Normalize val
  3557. if (typeof val === 'string') {
  3558. val = Buffer.from(val, encoding)
  3559. }
  3560. // Finally, search either indexOf (if dir is true) or lastIndexOf
  3561. if (Buffer.isBuffer(val)) {
  3562. // Special case: looking for empty string/buffer always fails
  3563. if (val.length === 0) {
  3564. return -1
  3565. }
  3566. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  3567. } else if (typeof val === 'number') {
  3568. val = val & 0xFF // Search for a byte value [0-255]
  3569. if (typeof Uint8Array.prototype.indexOf === 'function') {
  3570. if (dir) {
  3571. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  3572. } else {
  3573. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  3574. }
  3575. }
  3576. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  3577. }
  3578. throw new TypeError('val must be string, number or Buffer')
  3579. }
  3580. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  3581. var indexSize = 1
  3582. var arrLength = arr.length
  3583. var valLength = val.length
  3584. if (encoding !== undefined) {
  3585. encoding = String(encoding).toLowerCase()
  3586. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  3587. encoding === 'utf16le' || encoding === 'utf-16le') {
  3588. if (arr.length < 2 || val.length < 2) {
  3589. return -1
  3590. }
  3591. indexSize = 2
  3592. arrLength /= 2
  3593. valLength /= 2
  3594. byteOffset /= 2
  3595. }
  3596. }
  3597. function read (buf, i) {
  3598. if (indexSize === 1) {
  3599. return buf[i]
  3600. } else {
  3601. return buf.readUInt16BE(i * indexSize)
  3602. }
  3603. }
  3604. var i
  3605. if (dir) {
  3606. var foundIndex = -1
  3607. for (i = byteOffset; i < arrLength; i++) {
  3608. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  3609. if (foundIndex === -1) foundIndex = i
  3610. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  3611. } else {
  3612. if (foundIndex !== -1) i -= i - foundIndex
  3613. foundIndex = -1
  3614. }
  3615. }
  3616. } else {
  3617. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  3618. for (i = byteOffset; i >= 0; i--) {
  3619. var found = true
  3620. for (var j = 0; j < valLength; j++) {
  3621. if (read(arr, i + j) !== read(val, j)) {
  3622. found = false
  3623. break
  3624. }
  3625. }
  3626. if (found) return i
  3627. }
  3628. }
  3629. return -1
  3630. }
  3631. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  3632. return this.indexOf(val, byteOffset, encoding) !== -1
  3633. }
  3634. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  3635. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  3636. }
  3637. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  3638. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  3639. }
  3640. function hexWrite (buf, string, offset, length) {
  3641. offset = Number(offset) || 0
  3642. var remaining = buf.length - offset
  3643. if (!length) {
  3644. length = remaining
  3645. } else {
  3646. length = Number(length)
  3647. if (length > remaining) {
  3648. length = remaining
  3649. }
  3650. }
  3651. var strLen = string.length
  3652. if (length > strLen / 2) {
  3653. length = strLen / 2
  3654. }
  3655. for (var i = 0; i < length; ++i) {
  3656. var parsed = parseInt(string.substr(i * 2, 2), 16)
  3657. if (numberIsNaN(parsed)) return i
  3658. buf[offset + i] = parsed
  3659. }
  3660. return i
  3661. }
  3662. function utf8Write (buf, string, offset, length) {
  3663. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  3664. }
  3665. function asciiWrite (buf, string, offset, length) {
  3666. return blitBuffer(asciiToBytes(string), buf, offset, length)
  3667. }
  3668. function latin1Write (buf, string, offset, length) {
  3669. return asciiWrite(buf, string, offset, length)
  3670. }
  3671. function base64Write (buf, string, offset, length) {
  3672. return blitBuffer(base64ToBytes(string), buf, offset, length)
  3673. }
  3674. function ucs2Write (buf, string, offset, length) {
  3675. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  3676. }
  3677. Buffer.prototype.write = function write (string, offset, length, encoding) {
  3678. // Buffer#write(string)
  3679. if (offset === undefined) {
  3680. encoding = 'utf8'
  3681. length = this.length
  3682. offset = 0
  3683. // Buffer#write(string, encoding)
  3684. } else if (length === undefined && typeof offset === 'string') {
  3685. encoding = offset
  3686. length = this.length
  3687. offset = 0
  3688. // Buffer#write(string, offset[, length][, encoding])
  3689. } else if (isFinite(offset)) {
  3690. offset = offset >>> 0
  3691. if (isFinite(length)) {
  3692. length = length >>> 0
  3693. if (encoding === undefined) encoding = 'utf8'
  3694. } else {
  3695. encoding = length
  3696. length = undefined
  3697. }
  3698. } else {
  3699. throw new Error(
  3700. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  3701. )
  3702. }
  3703. var remaining = this.length - offset
  3704. if (length === undefined || length > remaining) length = remaining
  3705. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  3706. throw new RangeError('Attempt to write outside buffer bounds')
  3707. }
  3708. if (!encoding) encoding = 'utf8'
  3709. var loweredCase = false
  3710. for (;;) {
  3711. switch (encoding) {
  3712. case 'hex':
  3713. return hexWrite(this, string, offset, length)
  3714. case 'utf8':
  3715. case 'utf-8':
  3716. return utf8Write(this, string, offset, length)
  3717. case 'ascii':
  3718. return asciiWrite(this, string, offset, length)
  3719. case 'latin1':
  3720. case 'binary':
  3721. return latin1Write(this, string, offset, length)
  3722. case 'base64':
  3723. // Warning: maxLength not taken into account in base64Write
  3724. return base64Write(this, string, offset, length)
  3725. case 'ucs2':
  3726. case 'ucs-2':
  3727. case 'utf16le':
  3728. case 'utf-16le':
  3729. return ucs2Write(this, string, offset, length)
  3730. default:
  3731. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  3732. encoding = ('' + encoding).toLowerCase()
  3733. loweredCase = true
  3734. }
  3735. }
  3736. }
  3737. Buffer.prototype.toJSON = function toJSON () {
  3738. return {
  3739. type: 'Buffer',
  3740. data: Array.prototype.slice.call(this._arr || this, 0)
  3741. }
  3742. }
  3743. function base64Slice (buf, start, end) {
  3744. if (start === 0 && end === buf.length) {
  3745. return base64.fromByteArray(buf)
  3746. } else {
  3747. return base64.fromByteArray(buf.slice(start, end))
  3748. }
  3749. }
  3750. function utf8Slice (buf, start, end) {
  3751. end = Math.min(buf.length, end)
  3752. var res = []
  3753. var i = start
  3754. while (i < end) {
  3755. var firstByte = buf[i]
  3756. var codePoint = null
  3757. var bytesPerSequence = (firstByte > 0xEF) ? 4
  3758. : (firstByte > 0xDF) ? 3
  3759. : (firstByte > 0xBF) ? 2
  3760. : 1
  3761. if (i + bytesPerSequence <= end) {
  3762. var secondByte, thirdByte, fourthByte, tempCodePoint
  3763. switch (bytesPerSequence) {
  3764. case 1:
  3765. if (firstByte < 0x80) {
  3766. codePoint = firstByte
  3767. }
  3768. break
  3769. case 2:
  3770. secondByte = buf[i + 1]
  3771. if ((secondByte & 0xC0) === 0x80) {
  3772. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  3773. if (tempCodePoint > 0x7F) {
  3774. codePoint = tempCodePoint
  3775. }
  3776. }
  3777. break
  3778. case 3:
  3779. secondByte = buf[i + 1]
  3780. thirdByte = buf[i + 2]
  3781. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  3782. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  3783. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  3784. codePoint = tempCodePoint
  3785. }
  3786. }
  3787. break
  3788. case 4:
  3789. secondByte = buf[i + 1]
  3790. thirdByte = buf[i + 2]
  3791. fourthByte = buf[i + 3]
  3792. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  3793. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  3794. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  3795. codePoint = tempCodePoint
  3796. }
  3797. }
  3798. }
  3799. }
  3800. if (codePoint === null) {
  3801. // we did not generate a valid codePoint so insert a
  3802. // replacement char (U+FFFD) and advance only 1 byte
  3803. codePoint = 0xFFFD
  3804. bytesPerSequence = 1
  3805. } else if (codePoint > 0xFFFF) {
  3806. // encode to utf16 (surrogate pair dance)
  3807. codePoint -= 0x10000
  3808. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  3809. codePoint = 0xDC00 | codePoint & 0x3FF
  3810. }
  3811. res.push(codePoint)
  3812. i += bytesPerSequence
  3813. }
  3814. return decodeCodePointsArray(res)
  3815. }
  3816. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  3817. // the lowest limit is Chrome, with 0x10000 args.
  3818. // We go 1 magnitude less, for safety
  3819. var MAX_ARGUMENTS_LENGTH = 0x1000
  3820. function decodeCodePointsArray (codePoints) {
  3821. var len = codePoints.length
  3822. if (len <= MAX_ARGUMENTS_LENGTH) {
  3823. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  3824. }
  3825. // Decode in chunks to avoid "call stack size exceeded".
  3826. var res = ''
  3827. var i = 0
  3828. while (i < len) {
  3829. res += String.fromCharCode.apply(
  3830. String,
  3831. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  3832. )
  3833. }
  3834. return res
  3835. }
  3836. function asciiSlice (buf, start, end) {
  3837. var ret = ''
  3838. end = Math.min(buf.length, end)
  3839. for (var i = start; i < end; ++i) {
  3840. ret += String.fromCharCode(buf[i] & 0x7F)
  3841. }
  3842. return ret
  3843. }
  3844. function latin1Slice (buf, start, end) {
  3845. var ret = ''
  3846. end = Math.min(buf.length, end)
  3847. for (var i = start; i < end; ++i) {
  3848. ret += String.fromCharCode(buf[i])
  3849. }
  3850. return ret
  3851. }
  3852. function hexSlice (buf, start, end) {
  3853. var len = buf.length
  3854. if (!start || start < 0) start = 0
  3855. if (!end || end < 0 || end > len) end = len
  3856. var out = ''
  3857. for (var i = start; i < end; ++i) {
  3858. out += toHex(buf[i])
  3859. }
  3860. return out
  3861. }
  3862. function utf16leSlice (buf, start, end) {
  3863. var bytes = buf.slice(start, end)
  3864. var res = ''
  3865. for (var i = 0; i < bytes.length; i += 2) {
  3866. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  3867. }
  3868. return res
  3869. }
  3870. Buffer.prototype.slice = function slice (start, end) {
  3871. var len = this.length
  3872. start = ~~start
  3873. end = end === undefined ? len : ~~end
  3874. if (start < 0) {
  3875. start += len
  3876. if (start < 0) start = 0
  3877. } else if (start > len) {
  3878. start = len
  3879. }
  3880. if (end < 0) {
  3881. end += len
  3882. if (end < 0) end = 0
  3883. } else if (end > len) {
  3884. end = len
  3885. }
  3886. if (end < start) end = start
  3887. var newBuf = this.subarray(start, end)
  3888. // Return an augmented `Uint8Array` instance
  3889. newBuf.__proto__ = Buffer.prototype
  3890. return newBuf
  3891. }
  3892. /*
  3893. * Need to make sure that buffer isn't trying to write out of bounds.
  3894. */
  3895. function checkOffset (offset, ext, length) {
  3896. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  3897. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  3898. }
  3899. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  3900. offset = offset >>> 0
  3901. byteLength = byteLength >>> 0
  3902. if (!noAssert) checkOffset(offset, byteLength, this.length)
  3903. var val = this[offset]
  3904. var mul = 1
  3905. var i = 0
  3906. while (++i < byteLength && (mul *= 0x100)) {
  3907. val += this[offset + i] * mul
  3908. }
  3909. return val
  3910. }
  3911. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  3912. offset = offset >>> 0
  3913. byteLength = byteLength >>> 0
  3914. if (!noAssert) {
  3915. checkOffset(offset, byteLength, this.length)
  3916. }
  3917. var val = this[offset + --byteLength]
  3918. var mul = 1
  3919. while (byteLength > 0 && (mul *= 0x100)) {
  3920. val += this[offset + --byteLength] * mul
  3921. }
  3922. return val
  3923. }
  3924. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  3925. offset = offset >>> 0
  3926. if (!noAssert) checkOffset(offset, 1, this.length)
  3927. return this[offset]
  3928. }
  3929. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  3930. offset = offset >>> 0
  3931. if (!noAssert) checkOffset(offset, 2, this.length)
  3932. return this[offset] | (this[offset + 1] << 8)
  3933. }
  3934. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  3935. offset = offset >>> 0
  3936. if (!noAssert) checkOffset(offset, 2, this.length)
  3937. return (this[offset] << 8) | this[offset + 1]
  3938. }
  3939. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  3940. offset = offset >>> 0
  3941. if (!noAssert) checkOffset(offset, 4, this.length)
  3942. return ((this[offset]) |
  3943. (this[offset + 1] << 8) |
  3944. (this[offset + 2] << 16)) +
  3945. (this[offset + 3] * 0x1000000)
  3946. }
  3947. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  3948. offset = offset >>> 0
  3949. if (!noAssert) checkOffset(offset, 4, this.length)
  3950. return (this[offset] * 0x1000000) +
  3951. ((this[offset + 1] << 16) |
  3952. (this[offset + 2] << 8) |
  3953. this[offset + 3])
  3954. }
  3955. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  3956. offset = offset >>> 0
  3957. byteLength = byteLength >>> 0
  3958. if (!noAssert) checkOffset(offset, byteLength, this.length)
  3959. var val = this[offset]
  3960. var mul = 1
  3961. var i = 0
  3962. while (++i < byteLength && (mul *= 0x100)) {
  3963. val += this[offset + i] * mul
  3964. }
  3965. mul *= 0x80
  3966. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  3967. return val
  3968. }
  3969. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  3970. offset = offset >>> 0
  3971. byteLength = byteLength >>> 0
  3972. if (!noAssert) checkOffset(offset, byteLength, this.length)
  3973. var i = byteLength
  3974. var mul = 1
  3975. var val = this[offset + --i]
  3976. while (i > 0 && (mul *= 0x100)) {
  3977. val += this[offset + --i] * mul
  3978. }
  3979. mul *= 0x80
  3980. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  3981. return val
  3982. }
  3983. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  3984. offset = offset >>> 0
  3985. if (!noAssert) checkOffset(offset, 1, this.length)
  3986. if (!(this[offset] & 0x80)) return (this[offset])
  3987. return ((0xff - this[offset] + 1) * -1)
  3988. }
  3989. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  3990. offset = offset >>> 0
  3991. if (!noAssert) checkOffset(offset, 2, this.length)
  3992. var val = this[offset] | (this[offset + 1] << 8)
  3993. return (val & 0x8000) ? val | 0xFFFF0000 : val
  3994. }
  3995. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  3996. offset = offset >>> 0
  3997. if (!noAssert) checkOffset(offset, 2, this.length)
  3998. var val = this[offset + 1] | (this[offset] << 8)
  3999. return (val & 0x8000) ? val | 0xFFFF0000 : val
  4000. }
  4001. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  4002. offset = offset >>> 0
  4003. if (!noAssert) checkOffset(offset, 4, this.length)
  4004. return (this[offset]) |
  4005. (this[offset + 1] << 8) |
  4006. (this[offset + 2] << 16) |
  4007. (this[offset + 3] << 24)
  4008. }
  4009. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  4010. offset = offset >>> 0
  4011. if (!noAssert) checkOffset(offset, 4, this.length)
  4012. return (this[offset] << 24) |
  4013. (this[offset + 1] << 16) |
  4014. (this[offset + 2] << 8) |
  4015. (this[offset + 3])
  4016. }
  4017. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  4018. offset = offset >>> 0
  4019. if (!noAssert) checkOffset(offset, 4, this.length)
  4020. return ieee754.read(this, offset, true, 23, 4)
  4021. }
  4022. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  4023. offset = offset >>> 0
  4024. if (!noAssert) checkOffset(offset, 4, this.length)
  4025. return ieee754.read(this, offset, false, 23, 4)
  4026. }
  4027. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  4028. offset = offset >>> 0
  4029. if (!noAssert) checkOffset(offset, 8, this.length)
  4030. return ieee754.read(this, offset, true, 52, 8)
  4031. }
  4032. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  4033. offset = offset >>> 0
  4034. if (!noAssert) checkOffset(offset, 8, this.length)
  4035. return ieee754.read(this, offset, false, 52, 8)
  4036. }
  4037. function checkInt (buf, value, offset, ext, max, min) {
  4038. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  4039. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  4040. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  4041. }
  4042. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  4043. value = +value
  4044. offset = offset >>> 0
  4045. byteLength = byteLength >>> 0
  4046. if (!noAssert) {
  4047. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  4048. checkInt(this, value, offset, byteLength, maxBytes, 0)
  4049. }
  4050. var mul = 1
  4051. var i = 0
  4052. this[offset] = value & 0xFF
  4053. while (++i < byteLength && (mul *= 0x100)) {
  4054. this[offset + i] = (value / mul) & 0xFF
  4055. }
  4056. return offset + byteLength
  4057. }
  4058. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  4059. value = +value
  4060. offset = offset >>> 0
  4061. byteLength = byteLength >>> 0
  4062. if (!noAssert) {
  4063. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  4064. checkInt(this, value, offset, byteLength, maxBytes, 0)
  4065. }
  4066. var i = byteLength - 1
  4067. var mul = 1
  4068. this[offset + i] = value & 0xFF
  4069. while (--i >= 0 && (mul *= 0x100)) {
  4070. this[offset + i] = (value / mul) & 0xFF
  4071. }
  4072. return offset + byteLength
  4073. }
  4074. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  4075. value = +value
  4076. offset = offset >>> 0
  4077. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  4078. this[offset] = (value & 0xff)
  4079. return offset + 1
  4080. }
  4081. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  4082. value = +value
  4083. offset = offset >>> 0
  4084. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  4085. this[offset] = (value & 0xff)
  4086. this[offset + 1] = (value >>> 8)
  4087. return offset + 2
  4088. }
  4089. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  4090. value = +value
  4091. offset = offset >>> 0
  4092. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  4093. this[offset] = (value >>> 8)
  4094. this[offset + 1] = (value & 0xff)
  4095. return offset + 2
  4096. }
  4097. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  4098. value = +value
  4099. offset = offset >>> 0
  4100. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  4101. this[offset + 3] = (value >>> 24)
  4102. this[offset + 2] = (value >>> 16)
  4103. this[offset + 1] = (value >>> 8)
  4104. this[offset] = (value & 0xff)
  4105. return offset + 4
  4106. }
  4107. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  4108. value = +value
  4109. offset = offset >>> 0
  4110. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  4111. this[offset] = (value >>> 24)
  4112. this[offset + 1] = (value >>> 16)
  4113. this[offset + 2] = (value >>> 8)
  4114. this[offset + 3] = (value & 0xff)
  4115. return offset + 4
  4116. }
  4117. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  4118. value = +value
  4119. offset = offset >>> 0
  4120. if (!noAssert) {
  4121. var limit = Math.pow(2, (8 * byteLength) - 1)
  4122. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  4123. }
  4124. var i = 0
  4125. var mul = 1
  4126. var sub = 0
  4127. this[offset] = value & 0xFF
  4128. while (++i < byteLength && (mul *= 0x100)) {
  4129. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  4130. sub = 1
  4131. }
  4132. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  4133. }
  4134. return offset + byteLength
  4135. }
  4136. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  4137. value = +value
  4138. offset = offset >>> 0
  4139. if (!noAssert) {
  4140. var limit = Math.pow(2, (8 * byteLength) - 1)
  4141. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  4142. }
  4143. var i = byteLength - 1
  4144. var mul = 1
  4145. var sub = 0
  4146. this[offset + i] = value & 0xFF
  4147. while (--i >= 0 && (mul *= 0x100)) {
  4148. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  4149. sub = 1
  4150. }
  4151. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  4152. }
  4153. return offset + byteLength
  4154. }
  4155. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  4156. value = +value
  4157. offset = offset >>> 0
  4158. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  4159. if (value < 0) value = 0xff + value + 1
  4160. this[offset] = (value & 0xff)
  4161. return offset + 1
  4162. }
  4163. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  4164. value = +value
  4165. offset = offset >>> 0
  4166. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  4167. this[offset] = (value & 0xff)
  4168. this[offset + 1] = (value >>> 8)
  4169. return offset + 2
  4170. }
  4171. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  4172. value = +value
  4173. offset = offset >>> 0
  4174. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  4175. this[offset] = (value >>> 8)
  4176. this[offset + 1] = (value & 0xff)
  4177. return offset + 2
  4178. }
  4179. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  4180. value = +value
  4181. offset = offset >>> 0
  4182. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  4183. this[offset] = (value & 0xff)
  4184. this[offset + 1] = (value >>> 8)
  4185. this[offset + 2] = (value >>> 16)
  4186. this[offset + 3] = (value >>> 24)
  4187. return offset + 4
  4188. }
  4189. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  4190. value = +value
  4191. offset = offset >>> 0
  4192. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  4193. if (value < 0) value = 0xffffffff + value + 1
  4194. this[offset] = (value >>> 24)
  4195. this[offset + 1] = (value >>> 16)
  4196. this[offset + 2] = (value >>> 8)
  4197. this[offset + 3] = (value & 0xff)
  4198. return offset + 4
  4199. }
  4200. function checkIEEE754 (buf, value, offset, ext, max, min) {
  4201. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  4202. if (offset < 0) throw new RangeError('Index out of range')
  4203. }
  4204. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  4205. value = +value
  4206. offset = offset >>> 0
  4207. if (!noAssert) {
  4208. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  4209. }
  4210. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  4211. return offset + 4
  4212. }
  4213. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  4214. return writeFloat(this, value, offset, true, noAssert)
  4215. }
  4216. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  4217. return writeFloat(this, value, offset, false, noAssert)
  4218. }
  4219. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  4220. value = +value
  4221. offset = offset >>> 0
  4222. if (!noAssert) {
  4223. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  4224. }
  4225. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  4226. return offset + 8
  4227. }
  4228. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  4229. return writeDouble(this, value, offset, true, noAssert)
  4230. }
  4231. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  4232. return writeDouble(this, value, offset, false, noAssert)
  4233. }
  4234. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  4235. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  4236. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  4237. if (!start) start = 0
  4238. if (!end && end !== 0) end = this.length
  4239. if (targetStart >= target.length) targetStart = target.length
  4240. if (!targetStart) targetStart = 0
  4241. if (end > 0 && end < start) end = start
  4242. // Copy 0 bytes; we're done
  4243. if (end === start) return 0
  4244. if (target.length === 0 || this.length === 0) return 0
  4245. // Fatal error conditions
  4246. if (targetStart < 0) {
  4247. throw new RangeError('targetStart out of bounds')
  4248. }
  4249. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  4250. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  4251. // Are we oob?
  4252. if (end > this.length) end = this.length
  4253. if (target.length - targetStart < end - start) {
  4254. end = target.length - targetStart + start
  4255. }
  4256. var len = end - start
  4257. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  4258. // Use built-in when available, missing from IE11
  4259. this.copyWithin(targetStart, start, end)
  4260. } else if (this === target && start < targetStart && targetStart < end) {
  4261. // descending copy from end
  4262. for (var i = len - 1; i >= 0; --i) {
  4263. target[i + targetStart] = this[i + start]
  4264. }
  4265. } else {
  4266. Uint8Array.prototype.set.call(
  4267. target,
  4268. this.subarray(start, end),
  4269. targetStart
  4270. )
  4271. }
  4272. return len
  4273. }
  4274. // Usage:
  4275. // buffer.fill(number[, offset[, end]])
  4276. // buffer.fill(buffer[, offset[, end]])
  4277. // buffer.fill(string[, offset[, end]][, encoding])
  4278. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  4279. // Handle string cases:
  4280. if (typeof val === 'string') {
  4281. if (typeof start === 'string') {
  4282. encoding = start
  4283. start = 0
  4284. end = this.length
  4285. } else if (typeof end === 'string') {
  4286. encoding = end
  4287. end = this.length
  4288. }
  4289. if (encoding !== undefined && typeof encoding !== 'string') {
  4290. throw new TypeError('encoding must be a string')
  4291. }
  4292. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  4293. throw new TypeError('Unknown encoding: ' + encoding)
  4294. }
  4295. if (val.length === 1) {
  4296. var code = val.charCodeAt(0)
  4297. if ((encoding === 'utf8' && code < 128) ||
  4298. encoding === 'latin1') {
  4299. // Fast path: If `val` fits into a single byte, use that numeric value.
  4300. val = code
  4301. }
  4302. }
  4303. } else if (typeof val === 'number') {
  4304. val = val & 255
  4305. }
  4306. // Invalid ranges are not set to a default, so can range check early.
  4307. if (start < 0 || this.length < start || this.length < end) {
  4308. throw new RangeError('Out of range index')
  4309. }
  4310. if (end <= start) {
  4311. return this
  4312. }
  4313. start = start >>> 0
  4314. end = end === undefined ? this.length : end >>> 0
  4315. if (!val) val = 0
  4316. var i
  4317. if (typeof val === 'number') {
  4318. for (i = start; i < end; ++i) {
  4319. this[i] = val
  4320. }
  4321. } else {
  4322. var bytes = Buffer.isBuffer(val)
  4323. ? val
  4324. : Buffer.from(val, encoding)
  4325. var len = bytes.length
  4326. if (len === 0) {
  4327. throw new TypeError('The value "' + val +
  4328. '" is invalid for argument "value"')
  4329. }
  4330. for (i = 0; i < end - start; ++i) {
  4331. this[i + start] = bytes[i % len]
  4332. }
  4333. }
  4334. return this
  4335. }
  4336. // HELPER FUNCTIONS
  4337. // ================
  4338. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  4339. function base64clean (str) {
  4340. // Node takes equal signs as end of the Base64 encoding
  4341. str = str.split('=')[0]
  4342. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  4343. str = str.trim().replace(INVALID_BASE64_RE, '')
  4344. // Node converts strings with length < 2 to ''
  4345. if (str.length < 2) return ''
  4346. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  4347. while (str.length % 4 !== 0) {
  4348. str = str + '='
  4349. }
  4350. return str
  4351. }
  4352. function toHex (n) {
  4353. if (n < 16) return '0' + n.toString(16)
  4354. return n.toString(16)
  4355. }
  4356. function utf8ToBytes (string, units) {
  4357. units = units || Infinity
  4358. var codePoint
  4359. var length = string.length
  4360. var leadSurrogate = null
  4361. var bytes = []
  4362. for (var i = 0; i < length; ++i) {
  4363. codePoint = string.charCodeAt(i)
  4364. // is surrogate component
  4365. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  4366. // last char was a lead
  4367. if (!leadSurrogate) {
  4368. // no lead yet
  4369. if (codePoint > 0xDBFF) {
  4370. // unexpected trail
  4371. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4372. continue
  4373. } else if (i + 1 === length) {
  4374. // unpaired lead
  4375. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4376. continue
  4377. }
  4378. // valid lead
  4379. leadSurrogate = codePoint
  4380. continue
  4381. }
  4382. // 2 leads in a row
  4383. if (codePoint < 0xDC00) {
  4384. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4385. leadSurrogate = codePoint
  4386. continue
  4387. }
  4388. // valid surrogate pair
  4389. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  4390. } else if (leadSurrogate) {
  4391. // valid bmp char, but last char was a lead
  4392. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4393. }
  4394. leadSurrogate = null
  4395. // encode utf8
  4396. if (codePoint < 0x80) {
  4397. if ((units -= 1) < 0) break
  4398. bytes.push(codePoint)
  4399. } else if (codePoint < 0x800) {
  4400. if ((units -= 2) < 0) break
  4401. bytes.push(
  4402. codePoint >> 0x6 | 0xC0,
  4403. codePoint & 0x3F | 0x80
  4404. )
  4405. } else if (codePoint < 0x10000) {
  4406. if ((units -= 3) < 0) break
  4407. bytes.push(
  4408. codePoint >> 0xC | 0xE0,
  4409. codePoint >> 0x6 & 0x3F | 0x80,
  4410. codePoint & 0x3F | 0x80
  4411. )
  4412. } else if (codePoint < 0x110000) {
  4413. if ((units -= 4) < 0) break
  4414. bytes.push(
  4415. codePoint >> 0x12 | 0xF0,
  4416. codePoint >> 0xC & 0x3F | 0x80,
  4417. codePoint >> 0x6 & 0x3F | 0x80,
  4418. codePoint & 0x3F | 0x80
  4419. )
  4420. } else {
  4421. throw new Error('Invalid code point')
  4422. }
  4423. }
  4424. return bytes
  4425. }
  4426. function asciiToBytes (str) {
  4427. var byteArray = []
  4428. for (var i = 0; i < str.length; ++i) {
  4429. // Node's code seems to be doing this and not & 0x7F..
  4430. byteArray.push(str.charCodeAt(i) & 0xFF)
  4431. }
  4432. return byteArray
  4433. }
  4434. function utf16leToBytes (str, units) {
  4435. var c, hi, lo
  4436. var byteArray = []
  4437. for (var i = 0; i < str.length; ++i) {
  4438. if ((units -= 2) < 0) break
  4439. c = str.charCodeAt(i)
  4440. hi = c >> 8
  4441. lo = c % 256
  4442. byteArray.push(lo)
  4443. byteArray.push(hi)
  4444. }
  4445. return byteArray
  4446. }
  4447. function base64ToBytes (str) {
  4448. return base64.toByteArray(base64clean(str))
  4449. }
  4450. function blitBuffer (src, dst, offset, length) {
  4451. for (var i = 0; i < length; ++i) {
  4452. if ((i + offset >= dst.length) || (i >= src.length)) break
  4453. dst[i + offset] = src[i]
  4454. }
  4455. return i
  4456. }
  4457. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  4458. // the `instanceof` check but they should be treated as of that type.
  4459. // See: https://github.com/feross/buffer/issues/166
  4460. function isInstance (obj, type) {
  4461. return obj instanceof type ||
  4462. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  4463. obj.constructor.name === type.name)
  4464. }
  4465. function numberIsNaN (obj) {
  4466. // For IE11 support
  4467. return obj !== obj // eslint-disable-line no-self-compare
  4468. }
  4469. }).call(this,require("buffer").Buffer)
  4470. },{"base64-js":9,"buffer":10,"ieee754":11}],11:[function(require,module,exports){
  4471. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  4472. var e, m
  4473. var eLen = (nBytes * 8) - mLen - 1
  4474. var eMax = (1 << eLen) - 1
  4475. var eBias = eMax >> 1
  4476. var nBits = -7
  4477. var i = isLE ? (nBytes - 1) : 0
  4478. var d = isLE ? -1 : 1
  4479. var s = buffer[offset + i]
  4480. i += d
  4481. e = s & ((1 << (-nBits)) - 1)
  4482. s >>= (-nBits)
  4483. nBits += eLen
  4484. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  4485. m = e & ((1 << (-nBits)) - 1)
  4486. e >>= (-nBits)
  4487. nBits += mLen
  4488. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  4489. if (e === 0) {
  4490. e = 1 - eBias
  4491. } else if (e === eMax) {
  4492. return m ? NaN : ((s ? -1 : 1) * Infinity)
  4493. } else {
  4494. m = m + Math.pow(2, mLen)
  4495. e = e - eBias
  4496. }
  4497. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  4498. }
  4499. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  4500. var e, m, c
  4501. var eLen = (nBytes * 8) - mLen - 1
  4502. var eMax = (1 << eLen) - 1
  4503. var eBias = eMax >> 1
  4504. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  4505. var i = isLE ? 0 : (nBytes - 1)
  4506. var d = isLE ? 1 : -1
  4507. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  4508. value = Math.abs(value)
  4509. if (isNaN(value) || value === Infinity) {
  4510. m = isNaN(value) ? 1 : 0
  4511. e = eMax
  4512. } else {
  4513. e = Math.floor(Math.log(value) / Math.LN2)
  4514. if (value * (c = Math.pow(2, -e)) < 1) {
  4515. e--
  4516. c *= 2
  4517. }
  4518. if (e + eBias >= 1) {
  4519. value += rt / c
  4520. } else {
  4521. value += rt * Math.pow(2, 1 - eBias)
  4522. }
  4523. if (value * c >= 2) {
  4524. e++
  4525. c /= 2
  4526. }
  4527. if (e + eBias >= eMax) {
  4528. m = 0
  4529. e = eMax
  4530. } else if (e + eBias >= 1) {
  4531. m = ((value * c) - 1) * Math.pow(2, mLen)
  4532. e = e + eBias
  4533. } else {
  4534. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  4535. e = 0
  4536. }
  4537. }
  4538. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  4539. e = (e << mLen) | m
  4540. eLen += mLen
  4541. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  4542. buffer[offset + i - d] |= s * 128
  4543. }
  4544. },{}],12:[function(require,module,exports){
  4545. // shim for using process in browser
  4546. var process = module.exports = {};
  4547. // cached from whatever global is present so that test runners that stub it
  4548. // don't break things. But we need to wrap it in a try catch in case it is
  4549. // wrapped in strict mode code which doesn't define any globals. It's inside a
  4550. // function because try/catches deoptimize in certain engines.
  4551. var cachedSetTimeout;
  4552. var cachedClearTimeout;
  4553. function defaultSetTimout() {
  4554. throw new Error('setTimeout has not been defined');
  4555. }
  4556. function defaultClearTimeout () {
  4557. throw new Error('clearTimeout has not been defined');
  4558. }
  4559. (function () {
  4560. try {
  4561. if (typeof setTimeout === 'function') {
  4562. cachedSetTimeout = setTimeout;
  4563. } else {
  4564. cachedSetTimeout = defaultSetTimout;
  4565. }
  4566. } catch (e) {
  4567. cachedSetTimeout = defaultSetTimout;
  4568. }
  4569. try {
  4570. if (typeof clearTimeout === 'function') {
  4571. cachedClearTimeout = clearTimeout;
  4572. } else {
  4573. cachedClearTimeout = defaultClearTimeout;
  4574. }
  4575. } catch (e) {
  4576. cachedClearTimeout = defaultClearTimeout;
  4577. }
  4578. } ())
  4579. function runTimeout(fun) {
  4580. if (cachedSetTimeout === setTimeout) {
  4581. //normal enviroments in sane situations
  4582. return setTimeout(fun, 0);
  4583. }
  4584. // if setTimeout wasn't available but was latter defined
  4585. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  4586. cachedSetTimeout = setTimeout;
  4587. return setTimeout(fun, 0);
  4588. }
  4589. try {
  4590. // when when somebody has screwed with setTimeout but no I.E. maddness
  4591. return cachedSetTimeout(fun, 0);
  4592. } catch(e){
  4593. try {
  4594. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4595. return cachedSetTimeout.call(null, fun, 0);
  4596. } catch(e){
  4597. // 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
  4598. return cachedSetTimeout.call(this, fun, 0);
  4599. }
  4600. }
  4601. }
  4602. function runClearTimeout(marker) {
  4603. if (cachedClearTimeout === clearTimeout) {
  4604. //normal enviroments in sane situations
  4605. return clearTimeout(marker);
  4606. }
  4607. // if clearTimeout wasn't available but was latter defined
  4608. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  4609. cachedClearTimeout = clearTimeout;
  4610. return clearTimeout(marker);
  4611. }
  4612. try {
  4613. // when when somebody has screwed with setTimeout but no I.E. maddness
  4614. return cachedClearTimeout(marker);
  4615. } catch (e){
  4616. try {
  4617. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4618. return cachedClearTimeout.call(null, marker);
  4619. } catch (e){
  4620. // 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.
  4621. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  4622. return cachedClearTimeout.call(this, marker);
  4623. }
  4624. }
  4625. }
  4626. var queue = [];
  4627. var draining = false;
  4628. var currentQueue;
  4629. var queueIndex = -1;
  4630. function cleanUpNextTick() {
  4631. if (!draining || !currentQueue) {
  4632. return;
  4633. }
  4634. draining = false;
  4635. if (currentQueue.length) {
  4636. queue = currentQueue.concat(queue);
  4637. } else {
  4638. queueIndex = -1;
  4639. }
  4640. if (queue.length) {
  4641. drainQueue();
  4642. }
  4643. }
  4644. function drainQueue() {
  4645. if (draining) {
  4646. return;
  4647. }
  4648. var timeout = runTimeout(cleanUpNextTick);
  4649. draining = true;
  4650. var len = queue.length;
  4651. while(len) {
  4652. currentQueue = queue;
  4653. queue = [];
  4654. while (++queueIndex < len) {
  4655. if (currentQueue) {
  4656. currentQueue[queueIndex].run();
  4657. }
  4658. }
  4659. queueIndex = -1;
  4660. len = queue.length;
  4661. }
  4662. currentQueue = null;
  4663. draining = false;
  4664. runClearTimeout(timeout);
  4665. }
  4666. process.nextTick = function (fun) {
  4667. var args = new Array(arguments.length - 1);
  4668. if (arguments.length > 1) {
  4669. for (var i = 1; i < arguments.length; i++) {
  4670. args[i - 1] = arguments[i];
  4671. }
  4672. }
  4673. queue.push(new Item(fun, args));
  4674. if (queue.length === 1 && !draining) {
  4675. runTimeout(drainQueue);
  4676. }
  4677. };
  4678. // v8 likes predictible objects
  4679. function Item(fun, array) {
  4680. this.fun = fun;
  4681. this.array = array;
  4682. }
  4683. Item.prototype.run = function () {
  4684. this.fun.apply(null, this.array);
  4685. };
  4686. process.title = 'browser';
  4687. process.browser = true;
  4688. process.env = {};
  4689. process.argv = [];
  4690. process.version = ''; // empty string to avoid regexp issues
  4691. process.versions = {};
  4692. function noop() {}
  4693. process.on = noop;
  4694. process.addListener = noop;
  4695. process.once = noop;
  4696. process.off = noop;
  4697. process.removeListener = noop;
  4698. process.removeAllListeners = noop;
  4699. process.emit = noop;
  4700. process.prependListener = noop;
  4701. process.prependOnceListener = noop;
  4702. process.listeners = function (name) { return [] }
  4703. process.binding = function (name) {
  4704. throw new Error('process.binding is not supported');
  4705. };
  4706. process.cwd = function () { return '/' };
  4707. process.chdir = function (dir) {
  4708. throw new Error('process.chdir is not supported');
  4709. };
  4710. process.umask = function() { return 0; };
  4711. },{}]},{},[2]);