index.js 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445
  1. module.exports = (function() {
  2. var __MODS__ = {};
  3. var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
  4. var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
  5. var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
  6. var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
  7. __DEFINE__(1682324647500, function(require, module, exports) {
  8. // GENERATED FILE. DO NOT EDIT.
  9. var Long = (function(exports) {
  10. Object.defineProperty(exports, "__esModule", {
  11. value: true
  12. });
  13. exports.default = void 0;
  14. /**
  15. * @license
  16. * Copyright 2009 The Closure Library Authors
  17. * Copyright 2020 Daniel Wirtz / The long.js Authors.
  18. *
  19. * Licensed under the Apache License, Version 2.0 (the "License");
  20. * you may not use this file except in compliance with the License.
  21. * You may obtain a copy of the License at
  22. *
  23. * http://www.apache.org/licenses/LICENSE-2.0
  24. *
  25. * Unless required by applicable law or agreed to in writing, software
  26. * distributed under the License is distributed on an "AS IS" BASIS,
  27. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  28. * See the License for the specific language governing permissions and
  29. * limitations under the License.
  30. *
  31. * SPDX-License-Identifier: Apache-2.0
  32. */
  33. // WebAssembly optimizations to do native i64 multiplication and divide
  34. var wasm = null;
  35. try {
  36. wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports;
  37. } catch (e) {// no wasm support :(
  38. }
  39. /**
  40. * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
  41. * See the from* functions below for more convenient ways of constructing Longs.
  42. * @exports Long
  43. * @class A Long class for representing a 64 bit two's-complement integer value.
  44. * @param {number} low The low (signed) 32 bits of the long
  45. * @param {number} high The high (signed) 32 bits of the long
  46. * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
  47. * @constructor
  48. */
  49. function Long(low, high, unsigned) {
  50. /**
  51. * The low 32 bits as a signed value.
  52. * @type {number}
  53. */
  54. this.low = low | 0;
  55. /**
  56. * The high 32 bits as a signed value.
  57. * @type {number}
  58. */
  59. this.high = high | 0;
  60. /**
  61. * Whether unsigned or not.
  62. * @type {boolean}
  63. */
  64. this.unsigned = !!unsigned;
  65. } // The internal representation of a long is the two given signed, 32-bit values.
  66. // We use 32-bit pieces because these are the size of integers on which
  67. // Javascript performs bit-operations. For operations like addition and
  68. // multiplication, we split each number into 16 bit pieces, which can easily be
  69. // multiplied within Javascript's floating-point representation without overflow
  70. // or change in sign.
  71. //
  72. // In the algorithms below, we frequently reduce the negative case to the
  73. // positive case by negating the input(s) and then post-processing the result.
  74. // Note that we must ALWAYS check specially whether those values are MIN_VALUE
  75. // (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
  76. // a positive number, it overflows back into a negative). Not handling this
  77. // case would often result in infinite recursion.
  78. //
  79. // Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from*
  80. // methods on which they depend.
  81. /**
  82. * An indicator used to reliably determine if an object is a Long or not.
  83. * @type {boolean}
  84. * @const
  85. * @private
  86. */
  87. Long.prototype.__isLong__;
  88. Object.defineProperty(Long.prototype, "__isLong__", {
  89. value: true
  90. });
  91. /**
  92. * @function
  93. * @param {*} obj Object
  94. * @returns {boolean}
  95. * @inner
  96. */
  97. function isLong(obj) {
  98. return (obj && obj["__isLong__"]) === true;
  99. }
  100. /**
  101. * @function
  102. * @param {*} value number
  103. * @returns {number}
  104. * @inner
  105. */
  106. function ctz32(value) {
  107. var c = Math.clz32(value & -value);
  108. return value ? 31 - c : c;
  109. }
  110. /**
  111. * Tests if the specified object is a Long.
  112. * @function
  113. * @param {*} obj Object
  114. * @returns {boolean}
  115. */
  116. Long.isLong = isLong;
  117. /**
  118. * A cache of the Long representations of small integer values.
  119. * @type {!Object}
  120. * @inner
  121. */
  122. var INT_CACHE = {};
  123. /**
  124. * A cache of the Long representations of small unsigned integer values.
  125. * @type {!Object}
  126. * @inner
  127. */
  128. var UINT_CACHE = {};
  129. /**
  130. * @param {number} value
  131. * @param {boolean=} unsigned
  132. * @returns {!Long}
  133. * @inner
  134. */
  135. function fromInt(value, unsigned) {
  136. var obj, cachedObj, cache;
  137. if (unsigned) {
  138. value >>>= 0;
  139. if (cache = 0 <= value && value < 256) {
  140. cachedObj = UINT_CACHE[value];
  141. if (cachedObj) return cachedObj;
  142. }
  143. obj = fromBits(value, 0, true);
  144. if (cache) UINT_CACHE[value] = obj;
  145. return obj;
  146. } else {
  147. value |= 0;
  148. if (cache = -128 <= value && value < 128) {
  149. cachedObj = INT_CACHE[value];
  150. if (cachedObj) return cachedObj;
  151. }
  152. obj = fromBits(value, value < 0 ? -1 : 0, false);
  153. if (cache) INT_CACHE[value] = obj;
  154. return obj;
  155. }
  156. }
  157. /**
  158. * Returns a Long representing the given 32 bit integer value.
  159. * @function
  160. * @param {number} value The 32 bit integer in question
  161. * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
  162. * @returns {!Long} The corresponding Long value
  163. */
  164. Long.fromInt = fromInt;
  165. /**
  166. * @param {number} value
  167. * @param {boolean=} unsigned
  168. * @returns {!Long}
  169. * @inner
  170. */
  171. function fromNumber(value, unsigned) {
  172. if (isNaN(value)) return unsigned ? UZERO : ZERO;
  173. if (unsigned) {
  174. if (value < 0) return UZERO;
  175. if (value >= TWO_PWR_64_DBL) return MAX_UNSIGNED_VALUE;
  176. } else {
  177. if (value <= -TWO_PWR_63_DBL) return MIN_VALUE;
  178. if (value + 1 >= TWO_PWR_63_DBL) return MAX_VALUE;
  179. }
  180. if (value < 0) return fromNumber(-value, unsigned).neg();
  181. return fromBits(value % TWO_PWR_32_DBL | 0, value / TWO_PWR_32_DBL | 0, unsigned);
  182. }
  183. /**
  184. * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
  185. * @function
  186. * @param {number} value The number in question
  187. * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
  188. * @returns {!Long} The corresponding Long value
  189. */
  190. Long.fromNumber = fromNumber;
  191. /**
  192. * @param {number} lowBits
  193. * @param {number} highBits
  194. * @param {boolean=} unsigned
  195. * @returns {!Long}
  196. * @inner
  197. */
  198. function fromBits(lowBits, highBits, unsigned) {
  199. return new Long(lowBits, highBits, unsigned);
  200. }
  201. /**
  202. * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
  203. * assumed to use 32 bits.
  204. * @function
  205. * @param {number} lowBits The low 32 bits
  206. * @param {number} highBits The high 32 bits
  207. * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
  208. * @returns {!Long} The corresponding Long value
  209. */
  210. Long.fromBits = fromBits;
  211. /**
  212. * @function
  213. * @param {number} base
  214. * @param {number} exponent
  215. * @returns {number}
  216. * @inner
  217. */
  218. var pow_dbl = Math.pow; // Used 4 times (4*8 to 15+4)
  219. /**
  220. * @param {string} str
  221. * @param {(boolean|number)=} unsigned
  222. * @param {number=} radix
  223. * @returns {!Long}
  224. * @inner
  225. */
  226. function fromString(str, unsigned, radix) {
  227. if (str.length === 0) throw Error('empty string');
  228. if (typeof unsigned === 'number') {
  229. // For goog.math.long compatibility
  230. radix = unsigned;
  231. unsigned = false;
  232. } else {
  233. unsigned = !!unsigned;
  234. }
  235. if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity") return unsigned ? UZERO : ZERO;
  236. radix = radix || 10;
  237. if (radix < 2 || 36 < radix) throw RangeError('radix');
  238. var p;
  239. if ((p = str.indexOf('-')) > 0) throw Error('interior hyphen');else if (p === 0) {
  240. return fromString(str.substring(1), unsigned, radix).neg();
  241. } // Do several (8) digits each time through the loop, so as to
  242. // minimize the calls to the very expensive emulated div.
  243. var radixToPower = fromNumber(pow_dbl(radix, 8));
  244. var result = ZERO;
  245. for (var i = 0; i < str.length; i += 8) {
  246. var size = Math.min(8, str.length - i),
  247. value = parseInt(str.substring(i, i + size), radix);
  248. if (size < 8) {
  249. var power = fromNumber(pow_dbl(radix, size));
  250. result = result.mul(power).add(fromNumber(value));
  251. } else {
  252. result = result.mul(radixToPower);
  253. result = result.add(fromNumber(value));
  254. }
  255. }
  256. result.unsigned = unsigned;
  257. return result;
  258. }
  259. /**
  260. * Returns a Long representation of the given string, written using the specified radix.
  261. * @function
  262. * @param {string} str The textual representation of the Long
  263. * @param {(boolean|number)=} unsigned Whether unsigned or not, defaults to signed
  264. * @param {number=} radix The radix in which the text is written (2-36), defaults to 10
  265. * @returns {!Long} The corresponding Long value
  266. */
  267. Long.fromString = fromString;
  268. /**
  269. * @function
  270. * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val
  271. * @param {boolean=} unsigned
  272. * @returns {!Long}
  273. * @inner
  274. */
  275. function fromValue(val, unsigned) {
  276. if (typeof val === 'number') return fromNumber(val, unsigned);
  277. if (typeof val === 'string') return fromString(val, unsigned); // Throws for non-objects, converts non-instanceof Long:
  278. return fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned);
  279. }
  280. /**
  281. * Converts the specified value to a Long using the appropriate from* function for its type.
  282. * @function
  283. * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val Value
  284. * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
  285. * @returns {!Long}
  286. */
  287. Long.fromValue = fromValue; // NOTE: the compiler should inline these constant values below and then remove these variables, so there should be
  288. // no runtime penalty for these.
  289. /**
  290. * @type {number}
  291. * @const
  292. * @inner
  293. */
  294. var TWO_PWR_16_DBL = 1 << 16;
  295. /**
  296. * @type {number}
  297. * @const
  298. * @inner
  299. */
  300. var TWO_PWR_24_DBL = 1 << 24;
  301. /**
  302. * @type {number}
  303. * @const
  304. * @inner
  305. */
  306. var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
  307. /**
  308. * @type {number}
  309. * @const
  310. * @inner
  311. */
  312. var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
  313. /**
  314. * @type {number}
  315. * @const
  316. * @inner
  317. */
  318. var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
  319. /**
  320. * @type {!Long}
  321. * @const
  322. * @inner
  323. */
  324. var TWO_PWR_24 = fromInt(TWO_PWR_24_DBL);
  325. /**
  326. * @type {!Long}
  327. * @inner
  328. */
  329. var ZERO = fromInt(0);
  330. /**
  331. * Signed zero.
  332. * @type {!Long}
  333. */
  334. Long.ZERO = ZERO;
  335. /**
  336. * @type {!Long}
  337. * @inner
  338. */
  339. var UZERO = fromInt(0, true);
  340. /**
  341. * Unsigned zero.
  342. * @type {!Long}
  343. */
  344. Long.UZERO = UZERO;
  345. /**
  346. * @type {!Long}
  347. * @inner
  348. */
  349. var ONE = fromInt(1);
  350. /**
  351. * Signed one.
  352. * @type {!Long}
  353. */
  354. Long.ONE = ONE;
  355. /**
  356. * @type {!Long}
  357. * @inner
  358. */
  359. var UONE = fromInt(1, true);
  360. /**
  361. * Unsigned one.
  362. * @type {!Long}
  363. */
  364. Long.UONE = UONE;
  365. /**
  366. * @type {!Long}
  367. * @inner
  368. */
  369. var NEG_ONE = fromInt(-1);
  370. /**
  371. * Signed negative one.
  372. * @type {!Long}
  373. */
  374. Long.NEG_ONE = NEG_ONE;
  375. /**
  376. * @type {!Long}
  377. * @inner
  378. */
  379. var MAX_VALUE = fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0, false);
  380. /**
  381. * Maximum signed value.
  382. * @type {!Long}
  383. */
  384. Long.MAX_VALUE = MAX_VALUE;
  385. /**
  386. * @type {!Long}
  387. * @inner
  388. */
  389. var MAX_UNSIGNED_VALUE = fromBits(0xFFFFFFFF | 0, 0xFFFFFFFF | 0, true);
  390. /**
  391. * Maximum unsigned value.
  392. * @type {!Long}
  393. */
  394. Long.MAX_UNSIGNED_VALUE = MAX_UNSIGNED_VALUE;
  395. /**
  396. * @type {!Long}
  397. * @inner
  398. */
  399. var MIN_VALUE = fromBits(0, 0x80000000 | 0, false);
  400. /**
  401. * Minimum signed value.
  402. * @type {!Long}
  403. */
  404. Long.MIN_VALUE = MIN_VALUE;
  405. /**
  406. * @alias Long.prototype
  407. * @inner
  408. */
  409. var LongPrototype = Long.prototype;
  410. /**
  411. * Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
  412. * @this {!Long}
  413. * @returns {number}
  414. */
  415. LongPrototype.toInt = function toInt() {
  416. return this.unsigned ? this.low >>> 0 : this.low;
  417. };
  418. /**
  419. * Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
  420. * @this {!Long}
  421. * @returns {number}
  422. */
  423. LongPrototype.toNumber = function toNumber() {
  424. if (this.unsigned) return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
  425. return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
  426. };
  427. /**
  428. * Converts the Long to a string written in the specified radix.
  429. * @this {!Long}
  430. * @param {number=} radix Radix (2-36), defaults to 10
  431. * @returns {string}
  432. * @override
  433. * @throws {RangeError} If `radix` is out of range
  434. */
  435. LongPrototype.toString = function toString(radix) {
  436. radix = radix || 10;
  437. if (radix < 2 || 36 < radix) throw RangeError('radix');
  438. if (this.isZero()) return '0';
  439. if (this.isNegative()) {
  440. // Unsigned Longs are never negative
  441. if (this.eq(MIN_VALUE)) {
  442. // We need to change the Long value before it can be negated, so we remove
  443. // the bottom-most digit in this base and then recurse to do the rest.
  444. var radixLong = fromNumber(radix),
  445. div = this.div(radixLong),
  446. rem1 = div.mul(radixLong).sub(this);
  447. return div.toString(radix) + rem1.toInt().toString(radix);
  448. } else return '-' + this.neg().toString(radix);
  449. } // Do several (6) digits each time through the loop, so as to
  450. // minimize the calls to the very expensive emulated div.
  451. var radixToPower = fromNumber(pow_dbl(radix, 6), this.unsigned),
  452. rem = this;
  453. var result = '';
  454. while (true) {
  455. var remDiv = rem.div(radixToPower),
  456. intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0,
  457. digits = intval.toString(radix);
  458. rem = remDiv;
  459. if (rem.isZero()) return digits + result;else {
  460. while (digits.length < 6) digits = '0' + digits;
  461. result = '' + digits + result;
  462. }
  463. }
  464. };
  465. /**
  466. * Gets the high 32 bits as a signed integer.
  467. * @this {!Long}
  468. * @returns {number} Signed high bits
  469. */
  470. LongPrototype.getHighBits = function getHighBits() {
  471. return this.high;
  472. };
  473. /**
  474. * Gets the high 32 bits as an unsigned integer.
  475. * @this {!Long}
  476. * @returns {number} Unsigned high bits
  477. */
  478. LongPrototype.getHighBitsUnsigned = function getHighBitsUnsigned() {
  479. return this.high >>> 0;
  480. };
  481. /**
  482. * Gets the low 32 bits as a signed integer.
  483. * @this {!Long}
  484. * @returns {number} Signed low bits
  485. */
  486. LongPrototype.getLowBits = function getLowBits() {
  487. return this.low;
  488. };
  489. /**
  490. * Gets the low 32 bits as an unsigned integer.
  491. * @this {!Long}
  492. * @returns {number} Unsigned low bits
  493. */
  494. LongPrototype.getLowBitsUnsigned = function getLowBitsUnsigned() {
  495. return this.low >>> 0;
  496. };
  497. /**
  498. * Gets the number of bits needed to represent the absolute value of this Long.
  499. * @this {!Long}
  500. * @returns {number}
  501. */
  502. LongPrototype.getNumBitsAbs = function getNumBitsAbs() {
  503. if (this.isNegative()) // Unsigned Longs are never negative
  504. return this.eq(MIN_VALUE) ? 64 : this.neg().getNumBitsAbs();
  505. var val = this.high != 0 ? this.high : this.low;
  506. for (var bit = 31; bit > 0; bit--) if ((val & 1 << bit) != 0) break;
  507. return this.high != 0 ? bit + 33 : bit + 1;
  508. };
  509. /**
  510. * Tests if this Long's value equals zero.
  511. * @this {!Long}
  512. * @returns {boolean}
  513. */
  514. LongPrototype.isZero = function isZero() {
  515. return this.high === 0 && this.low === 0;
  516. };
  517. /**
  518. * Tests if this Long's value equals zero. This is an alias of {@link Long#isZero}.
  519. * @returns {boolean}
  520. */
  521. LongPrototype.eqz = LongPrototype.isZero;
  522. /**
  523. * Tests if this Long's value is negative.
  524. * @this {!Long}
  525. * @returns {boolean}
  526. */
  527. LongPrototype.isNegative = function isNegative() {
  528. return !this.unsigned && this.high < 0;
  529. };
  530. /**
  531. * Tests if this Long's value is positive or zero.
  532. * @this {!Long}
  533. * @returns {boolean}
  534. */
  535. LongPrototype.isPositive = function isPositive() {
  536. return this.unsigned || this.high >= 0;
  537. };
  538. /**
  539. * Tests if this Long's value is odd.
  540. * @this {!Long}
  541. * @returns {boolean}
  542. */
  543. LongPrototype.isOdd = function isOdd() {
  544. return (this.low & 1) === 1;
  545. };
  546. /**
  547. * Tests if this Long's value is even.
  548. * @this {!Long}
  549. * @returns {boolean}
  550. */
  551. LongPrototype.isEven = function isEven() {
  552. return (this.low & 1) === 0;
  553. };
  554. /**
  555. * Tests if this Long's value equals the specified's.
  556. * @this {!Long}
  557. * @param {!Long|number|string} other Other value
  558. * @returns {boolean}
  559. */
  560. LongPrototype.equals = function equals(other) {
  561. if (!isLong(other)) other = fromValue(other);
  562. if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1) return false;
  563. return this.high === other.high && this.low === other.low;
  564. };
  565. /**
  566. * Tests if this Long's value equals the specified's. This is an alias of {@link Long#equals}.
  567. * @function
  568. * @param {!Long|number|string} other Other value
  569. * @returns {boolean}
  570. */
  571. LongPrototype.eq = LongPrototype.equals;
  572. /**
  573. * Tests if this Long's value differs from the specified's.
  574. * @this {!Long}
  575. * @param {!Long|number|string} other Other value
  576. * @returns {boolean}
  577. */
  578. LongPrototype.notEquals = function notEquals(other) {
  579. return !this.eq(
  580. /* validates */
  581. other);
  582. };
  583. /**
  584. * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
  585. * @function
  586. * @param {!Long|number|string} other Other value
  587. * @returns {boolean}
  588. */
  589. LongPrototype.neq = LongPrototype.notEquals;
  590. /**
  591. * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
  592. * @function
  593. * @param {!Long|number|string} other Other value
  594. * @returns {boolean}
  595. */
  596. LongPrototype.ne = LongPrototype.notEquals;
  597. /**
  598. * Tests if this Long's value is less than the specified's.
  599. * @this {!Long}
  600. * @param {!Long|number|string} other Other value
  601. * @returns {boolean}
  602. */
  603. LongPrototype.lessThan = function lessThan(other) {
  604. return this.comp(
  605. /* validates */
  606. other) < 0;
  607. };
  608. /**
  609. * Tests if this Long's value is less than the specified's. This is an alias of {@link Long#lessThan}.
  610. * @function
  611. * @param {!Long|number|string} other Other value
  612. * @returns {boolean}
  613. */
  614. LongPrototype.lt = LongPrototype.lessThan;
  615. /**
  616. * Tests if this Long's value is less than or equal the specified's.
  617. * @this {!Long}
  618. * @param {!Long|number|string} other Other value
  619. * @returns {boolean}
  620. */
  621. LongPrototype.lessThanOrEqual = function lessThanOrEqual(other) {
  622. return this.comp(
  623. /* validates */
  624. other) <= 0;
  625. };
  626. /**
  627. * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
  628. * @function
  629. * @param {!Long|number|string} other Other value
  630. * @returns {boolean}
  631. */
  632. LongPrototype.lte = LongPrototype.lessThanOrEqual;
  633. /**
  634. * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
  635. * @function
  636. * @param {!Long|number|string} other Other value
  637. * @returns {boolean}
  638. */
  639. LongPrototype.le = LongPrototype.lessThanOrEqual;
  640. /**
  641. * Tests if this Long's value is greater than the specified's.
  642. * @this {!Long}
  643. * @param {!Long|number|string} other Other value
  644. * @returns {boolean}
  645. */
  646. LongPrototype.greaterThan = function greaterThan(other) {
  647. return this.comp(
  648. /* validates */
  649. other) > 0;
  650. };
  651. /**
  652. * Tests if this Long's value is greater than the specified's. This is an alias of {@link Long#greaterThan}.
  653. * @function
  654. * @param {!Long|number|string} other Other value
  655. * @returns {boolean}
  656. */
  657. LongPrototype.gt = LongPrototype.greaterThan;
  658. /**
  659. * Tests if this Long's value is greater than or equal the specified's.
  660. * @this {!Long}
  661. * @param {!Long|number|string} other Other value
  662. * @returns {boolean}
  663. */
  664. LongPrototype.greaterThanOrEqual = function greaterThanOrEqual(other) {
  665. return this.comp(
  666. /* validates */
  667. other) >= 0;
  668. };
  669. /**
  670. * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
  671. * @function
  672. * @param {!Long|number|string} other Other value
  673. * @returns {boolean}
  674. */
  675. LongPrototype.gte = LongPrototype.greaterThanOrEqual;
  676. /**
  677. * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
  678. * @function
  679. * @param {!Long|number|string} other Other value
  680. * @returns {boolean}
  681. */
  682. LongPrototype.ge = LongPrototype.greaterThanOrEqual;
  683. /**
  684. * Compares this Long's value with the specified's.
  685. * @this {!Long}
  686. * @param {!Long|number|string} other Other value
  687. * @returns {number} 0 if they are the same, 1 if the this is greater and -1
  688. * if the given one is greater
  689. */
  690. LongPrototype.compare = function compare(other) {
  691. if (!isLong(other)) other = fromValue(other);
  692. if (this.eq(other)) return 0;
  693. var thisNeg = this.isNegative(),
  694. otherNeg = other.isNegative();
  695. if (thisNeg && !otherNeg) return -1;
  696. if (!thisNeg && otherNeg) return 1; // At this point the sign bits are the same
  697. if (!this.unsigned) return this.sub(other).isNegative() ? -1 : 1; // Both are positive if at least one is unsigned
  698. return other.high >>> 0 > this.high >>> 0 || other.high === this.high && other.low >>> 0 > this.low >>> 0 ? -1 : 1;
  699. };
  700. /**
  701. * Compares this Long's value with the specified's. This is an alias of {@link Long#compare}.
  702. * @function
  703. * @param {!Long|number|string} other Other value
  704. * @returns {number} 0 if they are the same, 1 if the this is greater and -1
  705. * if the given one is greater
  706. */
  707. LongPrototype.comp = LongPrototype.compare;
  708. /**
  709. * Negates this Long's value.
  710. * @this {!Long}
  711. * @returns {!Long} Negated Long
  712. */
  713. LongPrototype.negate = function negate() {
  714. if (!this.unsigned && this.eq(MIN_VALUE)) return MIN_VALUE;
  715. return this.not().add(ONE);
  716. };
  717. /**
  718. * Negates this Long's value. This is an alias of {@link Long#negate}.
  719. * @function
  720. * @returns {!Long} Negated Long
  721. */
  722. LongPrototype.neg = LongPrototype.negate;
  723. /**
  724. * Returns the sum of this and the specified Long.
  725. * @this {!Long}
  726. * @param {!Long|number|string} addend Addend
  727. * @returns {!Long} Sum
  728. */
  729. LongPrototype.add = function add(addend) {
  730. if (!isLong(addend)) addend = fromValue(addend); // Divide each number into 4 chunks of 16 bits, and then sum the chunks.
  731. var a48 = this.high >>> 16;
  732. var a32 = this.high & 0xFFFF;
  733. var a16 = this.low >>> 16;
  734. var a00 = this.low & 0xFFFF;
  735. var b48 = addend.high >>> 16;
  736. var b32 = addend.high & 0xFFFF;
  737. var b16 = addend.low >>> 16;
  738. var b00 = addend.low & 0xFFFF;
  739. var c48 = 0,
  740. c32 = 0,
  741. c16 = 0,
  742. c00 = 0;
  743. c00 += a00 + b00;
  744. c16 += c00 >>> 16;
  745. c00 &= 0xFFFF;
  746. c16 += a16 + b16;
  747. c32 += c16 >>> 16;
  748. c16 &= 0xFFFF;
  749. c32 += a32 + b32;
  750. c48 += c32 >>> 16;
  751. c32 &= 0xFFFF;
  752. c48 += a48 + b48;
  753. c48 &= 0xFFFF;
  754. return fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned);
  755. };
  756. /**
  757. * Returns the difference of this and the specified Long.
  758. * @this {!Long}
  759. * @param {!Long|number|string} subtrahend Subtrahend
  760. * @returns {!Long} Difference
  761. */
  762. LongPrototype.subtract = function subtract(subtrahend) {
  763. if (!isLong(subtrahend)) subtrahend = fromValue(subtrahend);
  764. return this.add(subtrahend.neg());
  765. };
  766. /**
  767. * Returns the difference of this and the specified Long. This is an alias of {@link Long#subtract}.
  768. * @function
  769. * @param {!Long|number|string} subtrahend Subtrahend
  770. * @returns {!Long} Difference
  771. */
  772. LongPrototype.sub = LongPrototype.subtract;
  773. /**
  774. * Returns the product of this and the specified Long.
  775. * @this {!Long}
  776. * @param {!Long|number|string} multiplier Multiplier
  777. * @returns {!Long} Product
  778. */
  779. LongPrototype.multiply = function multiply(multiplier) {
  780. if (this.isZero()) return this;
  781. if (!isLong(multiplier)) multiplier = fromValue(multiplier); // use wasm support if present
  782. if (wasm) {
  783. var low = wasm["mul"](this.low, this.high, multiplier.low, multiplier.high);
  784. return fromBits(low, wasm["get_high"](), this.unsigned);
  785. }
  786. if (multiplier.isZero()) return this.unsigned ? UZERO : ZERO;
  787. if (this.eq(MIN_VALUE)) return multiplier.isOdd() ? MIN_VALUE : ZERO;
  788. if (multiplier.eq(MIN_VALUE)) return this.isOdd() ? MIN_VALUE : ZERO;
  789. if (this.isNegative()) {
  790. if (multiplier.isNegative()) return this.neg().mul(multiplier.neg());else return this.neg().mul(multiplier).neg();
  791. } else if (multiplier.isNegative()) return this.mul(multiplier.neg()).neg(); // If both longs are small, use float multiplication
  792. if (this.lt(TWO_PWR_24) && multiplier.lt(TWO_PWR_24)) return fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned); // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.
  793. // We can skip products that would overflow.
  794. var a48 = this.high >>> 16;
  795. var a32 = this.high & 0xFFFF;
  796. var a16 = this.low >>> 16;
  797. var a00 = this.low & 0xFFFF;
  798. var b48 = multiplier.high >>> 16;
  799. var b32 = multiplier.high & 0xFFFF;
  800. var b16 = multiplier.low >>> 16;
  801. var b00 = multiplier.low & 0xFFFF;
  802. var c48 = 0,
  803. c32 = 0,
  804. c16 = 0,
  805. c00 = 0;
  806. c00 += a00 * b00;
  807. c16 += c00 >>> 16;
  808. c00 &= 0xFFFF;
  809. c16 += a16 * b00;
  810. c32 += c16 >>> 16;
  811. c16 &= 0xFFFF;
  812. c16 += a00 * b16;
  813. c32 += c16 >>> 16;
  814. c16 &= 0xFFFF;
  815. c32 += a32 * b00;
  816. c48 += c32 >>> 16;
  817. c32 &= 0xFFFF;
  818. c32 += a16 * b16;
  819. c48 += c32 >>> 16;
  820. c32 &= 0xFFFF;
  821. c32 += a00 * b32;
  822. c48 += c32 >>> 16;
  823. c32 &= 0xFFFF;
  824. c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
  825. c48 &= 0xFFFF;
  826. return fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned);
  827. };
  828. /**
  829. * Returns the product of this and the specified Long. This is an alias of {@link Long#multiply}.
  830. * @function
  831. * @param {!Long|number|string} multiplier Multiplier
  832. * @returns {!Long} Product
  833. */
  834. LongPrototype.mul = LongPrototype.multiply;
  835. /**
  836. * Returns this Long divided by the specified. The result is signed if this Long is signed or
  837. * unsigned if this Long is unsigned.
  838. * @this {!Long}
  839. * @param {!Long|number|string} divisor Divisor
  840. * @returns {!Long} Quotient
  841. */
  842. LongPrototype.divide = function divide(divisor) {
  843. if (!isLong(divisor)) divisor = fromValue(divisor);
  844. if (divisor.isZero()) throw Error('division by zero'); // use wasm support if present
  845. if (wasm) {
  846. // guard against signed division overflow: the largest
  847. // negative number / -1 would be 1 larger than the largest
  848. // positive number, due to two's complement.
  849. if (!this.unsigned && this.high === -0x80000000 && divisor.low === -1 && divisor.high === -1) {
  850. // be consistent with non-wasm code path
  851. return this;
  852. }
  853. var low = (this.unsigned ? wasm["div_u"] : wasm["div_s"])(this.low, this.high, divisor.low, divisor.high);
  854. return fromBits(low, wasm["get_high"](), this.unsigned);
  855. }
  856. if (this.isZero()) return this.unsigned ? UZERO : ZERO;
  857. var approx, rem, res;
  858. if (!this.unsigned) {
  859. // This section is only relevant for signed longs and is derived from the
  860. // closure library as a whole.
  861. if (this.eq(MIN_VALUE)) {
  862. if (divisor.eq(ONE) || divisor.eq(NEG_ONE)) return MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
  863. else if (divisor.eq(MIN_VALUE)) return ONE;else {
  864. // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
  865. var halfThis = this.shr(1);
  866. approx = halfThis.div(divisor).shl(1);
  867. if (approx.eq(ZERO)) {
  868. return divisor.isNegative() ? ONE : NEG_ONE;
  869. } else {
  870. rem = this.sub(divisor.mul(approx));
  871. res = approx.add(rem.div(divisor));
  872. return res;
  873. }
  874. }
  875. } else if (divisor.eq(MIN_VALUE)) return this.unsigned ? UZERO : ZERO;
  876. if (this.isNegative()) {
  877. if (divisor.isNegative()) return this.neg().div(divisor.neg());
  878. return this.neg().div(divisor).neg();
  879. } else if (divisor.isNegative()) return this.div(divisor.neg()).neg();
  880. res = ZERO;
  881. } else {
  882. // The algorithm below has not been made for unsigned longs. It's therefore
  883. // required to take special care of the MSB prior to running it.
  884. if (!divisor.unsigned) divisor = divisor.toUnsigned();
  885. if (divisor.gt(this)) return UZERO;
  886. if (divisor.gt(this.shru(1))) // 15 >>> 1 = 7 ; with divisor = 8 ; true
  887. return UONE;
  888. res = UZERO;
  889. } // Repeat the following until the remainder is less than other: find a
  890. // floating-point that approximates remainder / other *from below*, add this
  891. // into the result, and subtract it from the remainder. It is critical that
  892. // the approximate value is less than or equal to the real value so that the
  893. // remainder never becomes negative.
  894. rem = this;
  895. while (rem.gte(divisor)) {
  896. // Approximate the result of division. This may be a little greater or
  897. // smaller than the actual value.
  898. approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber())); // We will tweak the approximate result by changing it in the 48-th digit or
  899. // the smallest non-fractional digit, whichever is larger.
  900. var log2 = Math.ceil(Math.log(approx) / Math.LN2),
  901. delta = log2 <= 48 ? 1 : pow_dbl(2, log2 - 48),
  902. // Decrease the approximation until it is smaller than the remainder. Note
  903. // that if it is too large, the product overflows and is negative.
  904. approxRes = fromNumber(approx),
  905. approxRem = approxRes.mul(divisor);
  906. while (approxRem.isNegative() || approxRem.gt(rem)) {
  907. approx -= delta;
  908. approxRes = fromNumber(approx, this.unsigned);
  909. approxRem = approxRes.mul(divisor);
  910. } // We know the answer can't be zero... and actually, zero would cause
  911. // infinite recursion since we would make no progress.
  912. if (approxRes.isZero()) approxRes = ONE;
  913. res = res.add(approxRes);
  914. rem = rem.sub(approxRem);
  915. }
  916. return res;
  917. };
  918. /**
  919. * Returns this Long divided by the specified. This is an alias of {@link Long#divide}.
  920. * @function
  921. * @param {!Long|number|string} divisor Divisor
  922. * @returns {!Long} Quotient
  923. */
  924. LongPrototype.div = LongPrototype.divide;
  925. /**
  926. * Returns this Long modulo the specified.
  927. * @this {!Long}
  928. * @param {!Long|number|string} divisor Divisor
  929. * @returns {!Long} Remainder
  930. */
  931. LongPrototype.modulo = function modulo(divisor) {
  932. if (!isLong(divisor)) divisor = fromValue(divisor); // use wasm support if present
  933. if (wasm) {
  934. var low = (this.unsigned ? wasm["rem_u"] : wasm["rem_s"])(this.low, this.high, divisor.low, divisor.high);
  935. return fromBits(low, wasm["get_high"](), this.unsigned);
  936. }
  937. return this.sub(this.div(divisor).mul(divisor));
  938. };
  939. /**
  940. * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
  941. * @function
  942. * @param {!Long|number|string} divisor Divisor
  943. * @returns {!Long} Remainder
  944. */
  945. LongPrototype.mod = LongPrototype.modulo;
  946. /**
  947. * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
  948. * @function
  949. * @param {!Long|number|string} divisor Divisor
  950. * @returns {!Long} Remainder
  951. */
  952. LongPrototype.rem = LongPrototype.modulo;
  953. /**
  954. * Returns the bitwise NOT of this Long.
  955. * @this {!Long}
  956. * @returns {!Long}
  957. */
  958. LongPrototype.not = function not() {
  959. return fromBits(~this.low, ~this.high, this.unsigned);
  960. };
  961. /**
  962. * Returns count leading zeros of this Long.
  963. * @this {!Long}
  964. * @returns {!number}
  965. */
  966. LongPrototype.countLeadingZeros = function countLeadingZeros() {
  967. return this.high ? Math.clz32(this.high) : Math.clz32(this.low) + 32;
  968. };
  969. /**
  970. * Returns count leading zeros. This is an alias of {@link Long#countLeadingZeros}.
  971. * @function
  972. * @param {!Long}
  973. * @returns {!number}
  974. */
  975. LongPrototype.clz = LongPrototype.countLeadingZeros;
  976. /**
  977. * Returns count trailing zeros of this Long.
  978. * @this {!Long}
  979. * @returns {!number}
  980. */
  981. LongPrototype.countTrailingZeros = function countTrailingZeros() {
  982. return this.low ? ctz32(this.low) : ctz32(this.high) + 32;
  983. };
  984. /**
  985. * Returns count trailing zeros. This is an alias of {@link Long#countTrailingZeros}.
  986. * @function
  987. * @param {!Long}
  988. * @returns {!number}
  989. */
  990. LongPrototype.ctz = LongPrototype.countTrailingZeros;
  991. /**
  992. * Returns the bitwise AND of this Long and the specified.
  993. * @this {!Long}
  994. * @param {!Long|number|string} other Other Long
  995. * @returns {!Long}
  996. */
  997. LongPrototype.and = function and(other) {
  998. if (!isLong(other)) other = fromValue(other);
  999. return fromBits(this.low & other.low, this.high & other.high, this.unsigned);
  1000. };
  1001. /**
  1002. * Returns the bitwise OR of this Long and the specified.
  1003. * @this {!Long}
  1004. * @param {!Long|number|string} other Other Long
  1005. * @returns {!Long}
  1006. */
  1007. LongPrototype.or = function or(other) {
  1008. if (!isLong(other)) other = fromValue(other);
  1009. return fromBits(this.low | other.low, this.high | other.high, this.unsigned);
  1010. };
  1011. /**
  1012. * Returns the bitwise XOR of this Long and the given one.
  1013. * @this {!Long}
  1014. * @param {!Long|number|string} other Other Long
  1015. * @returns {!Long}
  1016. */
  1017. LongPrototype.xor = function xor(other) {
  1018. if (!isLong(other)) other = fromValue(other);
  1019. return fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
  1020. };
  1021. /**
  1022. * Returns this Long with bits shifted to the left by the given amount.
  1023. * @this {!Long}
  1024. * @param {number|!Long} numBits Number of bits
  1025. * @returns {!Long} Shifted Long
  1026. */
  1027. LongPrototype.shiftLeft = function shiftLeft(numBits) {
  1028. if (isLong(numBits)) numBits = numBits.toInt();
  1029. if ((numBits &= 63) === 0) return this;else if (numBits < 32) return fromBits(this.low << numBits, this.high << numBits | this.low >>> 32 - numBits, this.unsigned);else return fromBits(0, this.low << numBits - 32, this.unsigned);
  1030. };
  1031. /**
  1032. * Returns this Long with bits shifted to the left by the given amount. This is an alias of {@link Long#shiftLeft}.
  1033. * @function
  1034. * @param {number|!Long} numBits Number of bits
  1035. * @returns {!Long} Shifted Long
  1036. */
  1037. LongPrototype.shl = LongPrototype.shiftLeft;
  1038. /**
  1039. * Returns this Long with bits arithmetically shifted to the right by the given amount.
  1040. * @this {!Long}
  1041. * @param {number|!Long} numBits Number of bits
  1042. * @returns {!Long} Shifted Long
  1043. */
  1044. LongPrototype.shiftRight = function shiftRight(numBits) {
  1045. if (isLong(numBits)) numBits = numBits.toInt();
  1046. if ((numBits &= 63) === 0) return this;else if (numBits < 32) return fromBits(this.low >>> numBits | this.high << 32 - numBits, this.high >> numBits, this.unsigned);else return fromBits(this.high >> numBits - 32, this.high >= 0 ? 0 : -1, this.unsigned);
  1047. };
  1048. /**
  1049. * Returns this Long with bits arithmetically shifted to the right by the given amount. This is an alias of {@link Long#shiftRight}.
  1050. * @function
  1051. * @param {number|!Long} numBits Number of bits
  1052. * @returns {!Long} Shifted Long
  1053. */
  1054. LongPrototype.shr = LongPrototype.shiftRight;
  1055. /**
  1056. * Returns this Long with bits logically shifted to the right by the given amount.
  1057. * @this {!Long}
  1058. * @param {number|!Long} numBits Number of bits
  1059. * @returns {!Long} Shifted Long
  1060. */
  1061. LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {
  1062. if (isLong(numBits)) numBits = numBits.toInt();
  1063. if ((numBits &= 63) === 0) return this;
  1064. if (numBits < 32) return fromBits(this.low >>> numBits | this.high << 32 - numBits, this.high >>> numBits, this.unsigned);
  1065. if (numBits === 32) return fromBits(this.high, 0, this.unsigned);
  1066. return fromBits(this.high >>> numBits - 32, 0, this.unsigned);
  1067. };
  1068. /**
  1069. * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.
  1070. * @function
  1071. * @param {number|!Long} numBits Number of bits
  1072. * @returns {!Long} Shifted Long
  1073. */
  1074. LongPrototype.shru = LongPrototype.shiftRightUnsigned;
  1075. /**
  1076. * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.
  1077. * @function
  1078. * @param {number|!Long} numBits Number of bits
  1079. * @returns {!Long} Shifted Long
  1080. */
  1081. LongPrototype.shr_u = LongPrototype.shiftRightUnsigned;
  1082. /**
  1083. * Returns this Long with bits rotated to the left by the given amount.
  1084. * @this {!Long}
  1085. * @param {number|!Long} numBits Number of bits
  1086. * @returns {!Long} Rotated Long
  1087. */
  1088. LongPrototype.rotateLeft = function rotateLeft(numBits) {
  1089. var b;
  1090. if (isLong(numBits)) numBits = numBits.toInt();
  1091. if ((numBits &= 63) === 0) return this;
  1092. if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);
  1093. if (numBits < 32) {
  1094. b = 32 - numBits;
  1095. return fromBits(this.low << numBits | this.high >>> b, this.high << numBits | this.low >>> b, this.unsigned);
  1096. }
  1097. numBits -= 32;
  1098. b = 32 - numBits;
  1099. return fromBits(this.high << numBits | this.low >>> b, this.low << numBits | this.high >>> b, this.unsigned);
  1100. };
  1101. /**
  1102. * Returns this Long with bits rotated to the left by the given amount. This is an alias of {@link Long#rotateLeft}.
  1103. * @function
  1104. * @param {number|!Long} numBits Number of bits
  1105. * @returns {!Long} Rotated Long
  1106. */
  1107. LongPrototype.rotl = LongPrototype.rotateLeft;
  1108. /**
  1109. * Returns this Long with bits rotated to the right by the given amount.
  1110. * @this {!Long}
  1111. * @param {number|!Long} numBits Number of bits
  1112. * @returns {!Long} Rotated Long
  1113. */
  1114. LongPrototype.rotateRight = function rotateRight(numBits) {
  1115. var b;
  1116. if (isLong(numBits)) numBits = numBits.toInt();
  1117. if ((numBits &= 63) === 0) return this;
  1118. if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);
  1119. if (numBits < 32) {
  1120. b = 32 - numBits;
  1121. return fromBits(this.high << b | this.low >>> numBits, this.low << b | this.high >>> numBits, this.unsigned);
  1122. }
  1123. numBits -= 32;
  1124. b = 32 - numBits;
  1125. return fromBits(this.low << b | this.high >>> numBits, this.high << b | this.low >>> numBits, this.unsigned);
  1126. };
  1127. /**
  1128. * Returns this Long with bits rotated to the right by the given amount. This is an alias of {@link Long#rotateRight}.
  1129. * @function
  1130. * @param {number|!Long} numBits Number of bits
  1131. * @returns {!Long} Rotated Long
  1132. */
  1133. LongPrototype.rotr = LongPrototype.rotateRight;
  1134. /**
  1135. * Converts this Long to signed.
  1136. * @this {!Long}
  1137. * @returns {!Long} Signed long
  1138. */
  1139. LongPrototype.toSigned = function toSigned() {
  1140. if (!this.unsigned) return this;
  1141. return fromBits(this.low, this.high, false);
  1142. };
  1143. /**
  1144. * Converts this Long to unsigned.
  1145. * @this {!Long}
  1146. * @returns {!Long} Unsigned long
  1147. */
  1148. LongPrototype.toUnsigned = function toUnsigned() {
  1149. if (this.unsigned) return this;
  1150. return fromBits(this.low, this.high, true);
  1151. };
  1152. /**
  1153. * Converts this Long to its byte representation.
  1154. * @param {boolean=} le Whether little or big endian, defaults to big endian
  1155. * @this {!Long}
  1156. * @returns {!Array.<number>} Byte representation
  1157. */
  1158. LongPrototype.toBytes = function toBytes(le) {
  1159. return le ? this.toBytesLE() : this.toBytesBE();
  1160. };
  1161. /**
  1162. * Converts this Long to its little endian byte representation.
  1163. * @this {!Long}
  1164. * @returns {!Array.<number>} Little endian byte representation
  1165. */
  1166. LongPrototype.toBytesLE = function toBytesLE() {
  1167. var hi = this.high,
  1168. lo = this.low;
  1169. return [lo & 0xff, lo >>> 8 & 0xff, lo >>> 16 & 0xff, lo >>> 24, hi & 0xff, hi >>> 8 & 0xff, hi >>> 16 & 0xff, hi >>> 24];
  1170. };
  1171. /**
  1172. * Converts this Long to its big endian byte representation.
  1173. * @this {!Long}
  1174. * @returns {!Array.<number>} Big endian byte representation
  1175. */
  1176. LongPrototype.toBytesBE = function toBytesBE() {
  1177. var hi = this.high,
  1178. lo = this.low;
  1179. return [hi >>> 24, hi >>> 16 & 0xff, hi >>> 8 & 0xff, hi & 0xff, lo >>> 24, lo >>> 16 & 0xff, lo >>> 8 & 0xff, lo & 0xff];
  1180. };
  1181. /**
  1182. * Creates a Long from its byte representation.
  1183. * @param {!Array.<number>} bytes Byte representation
  1184. * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
  1185. * @param {boolean=} le Whether little or big endian, defaults to big endian
  1186. * @returns {Long} The corresponding Long value
  1187. */
  1188. Long.fromBytes = function fromBytes(bytes, unsigned, le) {
  1189. return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned);
  1190. };
  1191. /**
  1192. * Creates a Long from its little endian byte representation.
  1193. * @param {!Array.<number>} bytes Little endian byte representation
  1194. * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
  1195. * @returns {Long} The corresponding Long value
  1196. */
  1197. Long.fromBytesLE = function fromBytesLE(bytes, unsigned) {
  1198. return new Long(bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24, bytes[4] | bytes[5] << 8 | bytes[6] << 16 | bytes[7] << 24, unsigned);
  1199. };
  1200. /**
  1201. * Creates a Long from its big endian byte representation.
  1202. * @param {!Array.<number>} bytes Big endian byte representation
  1203. * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
  1204. * @returns {Long} The corresponding Long value
  1205. */
  1206. Long.fromBytesBE = function fromBytesBE(bytes, unsigned) {
  1207. return new Long(bytes[4] << 24 | bytes[5] << 16 | bytes[6] << 8 | bytes[7], bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], unsigned);
  1208. };
  1209. var _default = Long;
  1210. exports.default = _default;
  1211. return "default" in exports ? exports.default : exports;
  1212. })({});
  1213. if (typeof define === 'function' && define.amd) define([], function() { return Long; });
  1214. else if (typeof module === 'object' && typeof exports==='object') module.exports = Long;
  1215. }, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
  1216. return __REQUIRE__(1682324647500);
  1217. })()
  1218. //miniprogram-npm-outsideDeps=[]
  1219. //# sourceMappingURL=index.js.map